Re: column: on update update? - Mailing list pgsql-admin

From Tom Lane
Subject Re: column: on update update?
Date
Msg-id 7703.1210174074@sss.pgh.pa.us
Whole thread Raw
In response to Re: column: on update update?  (CZUCZY Gergely <gergely.czuczy@harmless.hu>)
Responses Re: column: on update update? [solved]
List 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 by date:

Previous
From: CZUCZY Gergely
Date:
Subject: Re: column: on update update?
Next
From: mcravitz@att.net
Date:
Subject: Can't connect remotely