[SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Nikolay Samokhvalov
Hi, My knowledge of PostgreSQL's SQL is not good, but I know ISO/ANSI SQL:2003 (basics) quite well. I've encountered with following task. I have one SELECT statement with ORDER BY clause; and know, that result set for this SELECT contains row with ID = 1000 (just for example). I don't know the po

Re: [SQL] Export to XML

2005-11-19 Thread Nikolay Samokhvalov
You can try to use this patch: http://archives.postgresql.org/pgsql-patches/2005-09/msg00138.php This is implementation of basic functions of SQL/XML (14th part of SQL:2003, http://www.sqlx.org/) I've successfully applied it to 8.1 version - no troubles. On 11/11/05, Warren Murray <[EMAIL PROTEC

Re: [SQL] Sequential scan where Index scan expected.

2006-03-04 Thread Nikolay Samokhvalov
please, show '\d xx_thing_event' too :-) On 3/3/06, Bryce Nesbitt <[EMAIL PROTECTED]> wrote: > I'm getting sequential scans (and poor performance), on scans using my > primary keys. > Can anyone help figure out why? > > demo=# \d xx_thing > Table "public.xx_thing" > C

Re: [SQL] Check/unique constraint question

2006-03-05 Thread Nikolay Samokhvalov
Unfortunately, at the moment Postgres doesn't support subqueries in CHECK constraints, so it's seems that you should use trigger to check what you need, smth like this: CREATE OR REPLACE FUNCTION foo_check() RETURNS trigger AS $BODY$ BEGIN IF NEW.active = TRUE AND NEW.id IN ( SELECT id

Re: [SQL] Check/unique constraint question

2006-03-05 Thread Nikolay Samokhvalov
TRUE; END IF; END $BODY$ LANGUAGE plpgsql; ALTER TABLE foo ADD CONSTRAINT C_foo_iniq_if_true CHECK (active = FALSE OR id_is_valid(id)); On 3/5/06, Nikolay Samokhvalov <[EMAIL PROTECTED]> wrote: > Unfortunately, at the moment Postgres doesn't support subqueries in > CHECK con