Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 12DC02E0047 for ; Wed, 7 May 2008 11:58:57 -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 65110-06 for ; Wed, 7 May 2008 11:58:44 -0300 (ADT) X-Greylist: delayed 00:06:18.347732 by SQLgrey-1.7.6 Received: from marvin.harmless.hu (www.ssl.harmless.hu [195.56.55.205]) by developer.postgresql.org (Postfix) with ESMTP id 338F92E0042 for ; Wed, 7 May 2008 11:58:49 -0300 (ADT) Received: from fw.publishing.hu ([82.131.181.62] helo=twoflower.in.publishing.hu) by marvin.harmless.hu with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69 (FreeBSD)) (envelope-from ) id 1Jtl0P-000Pjs-BW; Wed, 07 May 2008 16:52:29 +0200 Date: Wed, 7 May 2008 16:52:26 +0200 From: CZUCZY Gergely To: Michael Monnerie Cc: pgsql-admin@postgresql.org Subject: Re: column: on update update? Message-ID: <20080507165226.7a49557a@twoflower.in.publishing.hu> In-Reply-To: <200805071649.03336@zmi.at> References: <200805071050.41450@zmi.at> <396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com> <200805071649.03336@zmi.at> Organization: Harmless Digital X-Mailer: Claws Mail 3.3.1 (GTK+ 2.10.11; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/ln_MUnkhSftoY9/Pc0FwvQz"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200805/52 X-Sequence-Number: 29136 --Sig_/ln_MUnkhSftoY9/Pc0FwvQz Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 7 May 2008 16:49:03 +0200 Michael Monnerie wrote: > > the other option is to add an after update trigger, and manually set > > lastupdate then. >=20 > Would that be correct? I never did it and looked purely into docs: >=20 > CREATE FUNCTION awlupdate() > AS 'UPDATE awl SET lastupdate=3DCURRENT_TIMESTAMP;' > LANGUAGE SQL; >=20 > CREATE TRIGGER awlupdate AFTER UPDATE ON awl FOR EACH ROW > EXECUTE PROCEDURE awlupdate(); I'd prefer this version: CREATE FUNCTION awlupdate RETURNS TRIGGER AS ' BEGIN NEW.lastupdate =3D now(); RETURN NEW; END' LANGUAGE plpgsql; CREATE TRIGGER... the same. But both methods are fine. The only thing is, the function must return TRIG= GER AFAIK. --=20 =C3=9Cdv=C3=B6lettel, Czuczy Gergely Harmless Digital Bt mailto: gergely.czuczy@harmless.hu Tel: +36-30-9702963 --Sig_/ln_MUnkhSftoY9/Pc0FwvQz Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) iD8DBQFIIcIszrC0WyuMkpsRAn3WAJ9y0GO8tStJ1zxeUegoEN71Q4pAFQCcDgrs u0IC6H2glTNir6MYQPBpKew= =PIwA -----END PGP SIGNATURE----- --Sig_/ln_MUnkhSftoY9/Pc0FwvQz--