Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group