Re: Modified FIFO queue and insert rule

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Modified FIFO queue and insert rule
Дата
Msg-id 46B9C145.8040402@magproductions.nl
обсуждение исходный текст
Ответ на Modified FIFO queue and insert rule  ("Leif B. Kristensen" <leif@solumslekt.org>)
Ответы Re: Modified FIFO queue and insert rule
Re: Modified FIFO queue and insert rule
Список 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@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 //

В списке pgsql-general по дате отправления:

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: List tables in reverse dependancy order
Следующее
От: "Leif B. Kristensen"
Дата:
Сообщение: Re: Modified FIFO queue and insert rule