Search Postgresql Archives

Re: Modified FIFO queue and insert rule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx

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 //

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux