From: | "Mark Bleeker" <mark(at)trilab(dot)com> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: automatically updated an attribute with the current time |
Date: | 2002-01-23 13:43:37 |
Message-ID: | NNEMIIOJEJFICLJOAEAKAECOCFAA.mark@trilab.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Jules Alberts
Sent: woensdag 23 januari 2002 12:28
To: pgsql-novice(at)postgresql(dot)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(at)postgresql(dot)org)
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-01-24 03:51:04 | Re: automatically updated an attribute with the current time |
Previous Message | Jules Alberts | 2002-01-23 11:27:38 | Re: automatically updated an attribute with the current time |