Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D96242E0076 for ; Thu, 8 May 2008 04:41:11 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86694-09 for ; Thu, 8 May 2008 04:41:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailsrv1.zmi.at (mailsrv1.zmi.at [212.69.162.198]) by developer.postgresql.org (Postfix) with ESMTP id EF7C22E0068 for ; Thu, 8 May 2008 04:41:07 -0300 (ADT) Received: from mailsrv.i.zmi.at (h081217054243.dyn.cm.kabsi.at [81.217.54.243]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mailsrv.i.zmi.at", Issuer "mailsrv.i.zmi.at" (not verified)) by mailsrv1.zmi.at (Postfix) with ESMTP id 145CBC5D for ; Thu, 8 May 2008 09:41:38 +0200 (CEST) Received: from saturn.i.zmi.at (saturn.i.zmi.at [10.0.0.2]) by mailsrv.i.zmi.at (Postfix) with ESMTP id 6E79ABFEB for ; Thu, 8 May 2008 09:40:27 +0200 (CEST) From: Michael Monnerie Organization: it-management http://it-management.at To: pgsql-admin@postgresql.org Subject: Re: column: on update update? [solved] Date: Thu, 8 May 2008 09:41:03 +0200 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) References: <200805071050.41450@zmi.at> <20080507165226.7a49557a@twoflower.in.publishing.hu> <7703.1210174074@sss.pgh.pa.us> In-Reply-To: <7703.1210174074@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1348169.qVX2Uvafgb"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200805080941.03990@zmi.at> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL=0.011 X-Spam-Level: X-Archive-Number: 200805/59 X-Sequence-Number: 29143 --nextPart1348169.qVX2Uvafgb Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Mittwoch, 7. Mai 2008 Tom Lane wrote: > No, the trigger command has to be BEFORE UPDATE not AFTER UPDATE for > this to work. =A0This 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=20 function name): CREATE FUNCTION awlupdate() RETURNS TRIGGER AS ' BEGIN NEW.lastupdate =3D now(); RETURN NEW; END' LANGUAGE plpgsql; CREATE TRIGGER awlupdate BEFORE UPDATE ON awl FOR EACH ROW EXECUTE=20 PROCEDURE awlupdate(); Thanks for your help! It's a bit complex just for an update, but it=20 works. :-) mfg zmi =2D-=20 // 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 --nextPart1348169.qVX2Uvafgb Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQBIIq6PzhSR9xwSCbQRAqWZAKCrjQxbSyuHO71ihPjjC0SJVpaCOACfekzP yVbq8tul3WDqnbY7DiQso6M= =Qu08 -----END PGP SIGNATURE----- --nextPart1348169.qVX2Uvafgb--