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@magproductions.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 //