Re: automatically updated an attribute with the current time

From: "Stephan Szabo" <acroyear_07030(at)yahoo(dot)com>
To: <julesa(at)arbodienst-limburg(dot)nl>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: automatically updated an attribute with the current time
Date: 2002-01-24 03:51:04
Message-ID: 014d01c1a48a$5a5f4640$77de010a@billshaw.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> create function au_col()
> returns opaque
> as 'begin
> old.mut_id = current_user;
> old.mut_timestamp = CURRENT_TIMESTAMP;
> return old;
> end;'
> language 'plpgsql';

As a note, while this works in your case, because you're changing
all the columns inside the trigger, in general, you want to be making
modifications to NEW and returning NEW on updates unless you
want to ignore the actual sets done by the update statement (which is
sometimes what you want).

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message cromwell 2002-01-24 05:15:07 trigger envy
Previous Message Mark Bleeker 2002-01-23 13:43:37 Re: automatically updated an attribute with the current time