Hi,
Thanks Steve and Jules, I have solved the problem with your help :)
I appreciate it very much!
Mark Bleeker
-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Jules Alberts
Sent: woensdag 23 januari 2002 12:28
To: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] automatically updated an attribute with the
current time
On 22 Jan 2002 at 12:02, Mark Bleeker wrote:
> Hello,
>
> I am trying to automatically update an attribute with the current time.
<snip>
from one newbie to another :)
i just figured it out yesterday:
-------------------------------------------------------
-- this is a templatetable, other tables inherit their
-- audit columns from it
drop table au_col;
create table au_col (
mut_id varchar(100) not null default current_user,
mut_timestamp timestamp not null default CURRENT_TIMESTAMP
);
-- function to change the values
drop function au_col();
create function au_col()
returns opaque
as 'begin
old.mut_id = current_user;
old.mut_timestamp = CURRENT_TIMESTAMP;
return old;
end;'
language 'plpgsql';
-- trigger to call the funtcion
drop trigger au_col on au_col;
create trigger au_col
before update or delete -- create is covered by defaults
on au_col
for each row
execute procedure au_col();
-------------------------------------------------------
HTH, HAND
--
Jules Alberts
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)