CZUCZY Gergely <gergely(dot)czuczy(at)harmless(dot)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