[GENERAL] conditional execution of insert/update-s

2009-01-22 Thread Dmitry Teslenko
Hello! Question is what's the easiest way to implement conditional execution of insert/update-s via psql interface? As far as I know there's following options: 1) create function in procedural language (plpgsql, for example); then call that function 2) update ... where ; insert ... (select ... whe

Re: [GENERAL] LIKE, "=" and fixed-width character fields

2008-11-11 Thread Dmitry Teslenko
On Mon, Nov 10, 2008 at 18:14, Richard Huxton <[EMAIL PROTECTED]> wrote: > Dmitry Teslenko wrote: >> Hello! >> There's table: >> CREATE TABLE table1 ( >> field1 CHARACTER(10), >> ... >> ); >> >> Then there's record: INS

[GENERAL] LIKE, "=" and fixed-width character fields

2008-11-10 Thread Dmitry Teslenko
Hello! There's table: CREATE TABLE table1 ( field1 CHARACTER(10), ... ); Then there's record: INSERT INTO table1(field1, ..) VALUES ('111', ...); Then I query it: SELECT * FROM table1 WHERE field1 '111'; When is LIKE no records matches query, when is = my record matches query.

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 18:47, Scott Marlowe <[EMAIL PROTECTED]> wrote: > What does "explain analyze select (your query here)" have to say? > Expalin analyze says it makes sequential scan on a table table1. On Thu, Aug 14, 2008 at 18:48, Gauthier, Dave <[EMAIL PROTECTED]> wrote: > Try this...

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 17:55, Igor Neyman <[EMAIL PROTECTED]> wrote: > > -Original Message----- > From: Dmitry Teslenko [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 14, 2008 6:57 AM > To: pgsql-general@postgresql.org > Subject: Strange query plan > > Hel

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 15:30, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Am Thursday, 14. August 2008 schrieb Dmitry Teslenko: >> SELECT SUM(...) FROM table1 WHERE field3 = 'ABC' AND field1 <> 1 >> GROUP BY field2 >> >> And planner p

[GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
Hello! I have following table: CREATE TABLE table1 ( field1 INTEGER NOT NULL, field2 INTEGER NOT NULL, field3 CHARACTER(30), ... some more numeric fields) I have also those indexes: CREATE UNIQUE INDEX idx1 ON table1 USING btree (field3, field2, field1) CREATE IN

[GENERAL] Right way to reject INSERTs and UPDATEs

2008-07-29 Thread Dmitry Teslenko
Hello! I have postgresql table that stores dome date range: it has range-begin and range-end columns of type date. I want to enforce that 1) range-begin would always before range-end and 2) there would be no range overlaps. First problem could be solved with CHECK constraint. The only possibility