Re: Modified FIFO queue and insert rule

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Modified FIFO queue and insert rule
Date: 2007-08-08 13:12:37
Message-ID: 46B9C145.8040402@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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);
>
> When I try to use the commented clause above, no records are written to
> the table at all! Why?

Do you use nextval() for that id?
In that case I think you immediately delete the record after inserting
it, as nextval gets called again in the delete statement, and thus id <>
NEW.id.

You should probably use a trigger (a before one maybe) instead of a rule.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif B. Kristensen 2007-08-08 13:28:08 Re: Modified FIFO queue and insert rule
Previous Message Pavel Stehule 2007-08-08 13:10:09 Re: List tables in reverse dependancy order