Re: [GENERAL] Modified FIFO queue and insert rule

2007-08-09 Thread Decibel!
On Thu, Aug 09, 2007 at 06:14:43PM +0200, Leif B. Kristensen wrote: > On Wednesday 8. August 2007 15:12, Alban Hertroys wrote: > >You should probably use a trigger (a before one maybe) instead of a > > rule. > > I tried that too, but I'm still quite shaky on how to write triggers, > and the same

Re: [GENERAL] Modified FIFO queue and insert rule

2007-08-09 Thread Leif B. Kristensen
On Wednesday 8. August 2007 15:12, Alban Hertroys wrote: >You should probably use a trigger (a before one maybe) instead of a > rule. I tried that too, but I'm still quite shaky on how to write triggers, and the same thing happened there: the inserted record was immediately deleted. I solved the

Re: [GENERAL] Modified FIFO queue and insert rule

2007-08-08 Thread Leif B. Kristensen
On Wednesday 8. August 2007 15:12, Alban Hertroys wrote: >Leif B. Kristensen wrote: >> CREATE RULE placelimit AS >> ON INSERT TO recent_places DO ALSO >> DELETE FROM recent_places >> WHERE >> -- this clause doesn't work >> -- (place_fk = NEW.place_fk AND id <> NEW.id) OR >>

Re: [GENERAL] Modified FIFO queue and insert rule

2007-08-08 Thread Alban Hertroys
Leif B. Kristensen wrote: > CREATE RULE placelimit AS > ON INSERT TO recent_places DO ALSO > DELETE FROM recent_places > WHERE > -- this clause doesn't work > -- (place_fk = NEW.place_fk AND id <> NEW.id) OR > id NOT IN (SELECT id FROM recent_places ORDER BY id DESC LIMIT 10

[GENERAL] Modified FIFO queue and insert rule

2007-08-08 Thread Leif B. Kristensen
I found an excellent description of how to implement a fifo que in PostgreSQL at Greg Mullane's blog: http://people.planetpostgresql.org/greg/index.php?/archives/89-Implementing-a-queue-in-SQL-Postgres-version.html I have used the 'rule' approach to implement a queue that generates a quick-list