From: Michael Monnerie <michael.monnerie@it-management.at>
To: pgsql-admin@postgresql.org
Subject: Re: column: on update update? [solved]
Date: Thu, 8 May 2008 09:41:03 +0200
Message-ID: <200805080941.03990@zmi.at> (raw)
In-Reply-To: <7703.1210174074@sss.pgh.pa.us>
References: <200805071050.41450@zmi.at>
<20080507165226.7a49557a@twoflower.in.publishing.hu>
<7703.1210174074@sss.pgh.pa.us>
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
Attachments:
signature.asc (application/pgp-signature, 193B) download
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: michael.monnerie@it-management.at
Subject: Re: column: on update update? [solved]
In-Reply-To: <200805080941.03990@zmi.at>
* 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