Re: column: on update update?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: column: on update update?
Дата
Msg-id 7703.1210174074@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: column: on update update?  (CZUCZY Gergely <gergely.czuczy@harmless.hu>)
Ответы Re: column: on update update? [solved]  (Michael Monnerie <michael.monnerie@it-management.at>)
Список pgsql-admin
CZUCZY Gergely <gergely.czuczy@harmless.hu> writes:
> I'd prefer this version:
> CREATE FUNCTION awlupdate RETURNS TRIGGER AS '
> BEGIN
>   NEW.lastupdate = now();
>   RETURN NEW;
> END' LANGUAGE plpgsql;

> CREATE TRIGGER... the same.

No, the trigger command has to be BEFORE UPDATE not AFTER UPDATE for
this to work.  This is definitely the better way though because the
row only gets updated once, not stored and then updated again
(in fact, I think you could get into an infinite loop if an AFTER
UPDATE trigger tries to update the row again).

            regards, tom lane

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

Предыдущее
От: CZUCZY Gergely
Дата:
Сообщение: Re: column: on update update?
Следующее
От: mcravitz@att.net
Дата:
Сообщение: Can't connect remotely