pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: CZUCZY Gergely <gergely.czuczy@harmless.hu>
To: Michael Monnerie <michael.monnerie@it-management.at>
Cc: pgsql-admin@postgresql.org
Subject: Re: column: on update update?
Date: Wed, 7 May 2008 16:52:26 +0200
Message-ID: <20080507165226.7a49557a@twoflower.in.publishing.hu> (raw)
In-Reply-To: <200805071649.03336@zmi.at>
References: <200805071050.41450@zmi.at>
	<396486430805070623p360b8eafp39683a287cdb3cc@mail.gmail.com>
	<200805071649.03336@zmi.at>

On Wed, 7 May 2008 16:49:03 +0200
Michael Monnerie <michael.monnerie@it-management.at> wrote:

> > the other option is to add an after update trigger, and manually set
> > lastupdate then.
> 
> Would that be correct? I never did it and looked purely into docs:
> 
> CREATE FUNCTION awlupdate()
>     AS 'UPDATE awl SET lastupdate=CURRENT_TIMESTAMP;'
>     LANGUAGE SQL;
> 
> 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 = now();
  RETURN NEW;
END' LANGUAGE plpgsql;
CREATE TRIGGER... the same.

But both methods are fine. The only thing is, the function must return TRIGGER
AFAIK.



-- 
Üdvölettel,

Czuczy Gergely
Harmless Digital Bt
mailto: gergely.czuczy@harmless.hu
Tel: +36-30-9702963

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (5+ messages)  latest in thread

Message-ID: <20080507165226.7a49557a@twoflower.in.publishing.hu>
Permalink:  ../20080507165226.7a49557a@twoflower.in.publishing.hu/
Also on:    postgresql.org/message-id/20080507165226.7a49557a@twoflower.in.publishing.hu

 · 

reply

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: gergely.czuczy@harmless.hu, michael.monnerie@it-management.at
  Subject: Re: column: on update update?
  In-Reply-To: <20080507165226.7a49557a@twoflower.in.publishing.hu>

* 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