Re: column: on update update? [solved]

Поиск
Список
Период
Сортировка
От Michael Monnerie
Тема Re: column: on update update? [solved]
Дата
Msg-id 200805080941.03990@zmi.at
обсуждение исходный текст
Ответ на Re: column: on update update?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
On Mittwoch, 7. Mai 2008 Tom Lane wrote:
> 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).

OK, here's the final correct syntax (examples missed the () at the
function name):

CREATE FUNCTION awlupdate() RETURNS TRIGGER AS '
BEGIN
    NEW.lastupdate = now();
    RETURN NEW;
END' LANGUAGE plpgsql;

CREATE TRIGGER awlupdate BEFORE UPDATE ON awl FOR EACH ROW EXECUTE
PROCEDURE awlupdate();

Thanks for your help! It's a bit complex just for an update, but it
works. :-)

mfg zmi
--
// Michael Monnerie, Ing.BSc    -----      http://it-management.at
// Tel: 0676/846 914 666                      .network.your.ideas.
// PGP Key:         "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38  500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net                   Key-ID: 1C1209B4

Вложения

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

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: postgres doesn't detect other end of the unix socket is gone...
Следующее
От: Guillaume Lelarge
Дата:
Сообщение: Re: Converting from 7.4.19 To 8.3.1 & want to use autovacuum