| From: | CZUCZY Gergely <gergely(dot)czuczy(at)harmless(dot)hu> |
|---|---|
| To: | Michael Monnerie <michael(dot)monnerie(at)it-management(dot)at> |
| Cc: | pgsql-admin(at)postgresql(dot)org |
| Subject: | Re: column: on update update? |
| Date: | 2008-05-07 14:52:26 |
| Message-ID: | 20080507165226.7a49557a@twoflower.in.publishing.hu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
On Wed, 7 May 2008 16:49:03 +0200
Michael Monnerie <michael(dot)monnerie(at)it-management(dot)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(dot)czuczy(at)harmless(dot)hu
Tel: +36-30-9702963
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2008-05-07 15:27:54 | Re: column: on update update? |
| Previous Message | bryan castillo | 2008-05-07 14:51:30 | How do I view the parameters of a running query? |