From: Tom Lane <tgl@sss.pgh.pa.us>
To: CZUCZY Gergely <gergely.czuczy@harmless.hu>
Cc: Michael Monnerie <michael.monnerie@it-management.at>
Cc: pgsql-admin@postgresql.org
Subject: Re: column: on update update?
Date: Wed, 07 May 2008 11:27:54 -0400
Message-ID: <7703.1210174074@sss.pgh.pa.us> (raw)
In-Reply-To: <20080507165226.7a49557a@twoflower.in.publishing.hu>
References: <200805071050.41450@zmi.at>
<396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com>
<200805071649.03336@zmi.at>
<20080507165226.7a49557a@twoflower.in.publishing.hu>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, gergely.czuczy@harmless.hu, michael.monnerie@it-management.at
Subject: Re: column: on update update?
In-Reply-To: <7703.1210174074@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox