Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: saving username and sysdate on insert/update

Re: saving username and sysdate on insert/update

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sat, 17 Apr 1999 21:39:08 +0200
Message-ID: <924378082.3230.0.rover.d4ee154e@news.demon.nl>


Hi Johnny,
before insert and before update triggers should do the trick create or replace trigger xyz on table_name before insert or update for each row
begin
if inserting then
new.addte := sysdate;
new.addusr := user;
else
new.upddte := sysdate;
new.updusr := user;
end if;
end;

This should be all. Please consult the doc for exact syntax, I never remember the correct sequence of components in the create line.

Hth,

Sybrand Bakker, Oracle DBA
johnny wrote in message <3718D3EF.7A71C1FE_at_sra.at>...
>hello,
>i want to save the username and the time in the record which the
>user has updated or inserted.
>therefor i've got the following cols:
>adddte .. should hold the date/time of record-creation (solved it by
>defaultvalue)
>upddte .. should hold the date/time of last update
>addusr .. should hold the username who inserted the record
>updusr .. should hold the username who updated the record last
>
>anybody has any suggestions?
>
>thanks in advance
>johnny
Received on Sat Apr 17 1999 - 14:39:08 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US