I want to create a table for auditing, i.e. a table where each database transaction is stored with user name and date. Example: I have the following tables:
create or replace trigger audittrigger
after insert or delete or update on demo1
for each row
begin
insert into audittable values(????, user, sysdate);
end;
/
Whenever a user inserts or deletes or updates data in the table demo1, I want to log the changings in the table audittable. It is no problem to store the user name and the date, but how can I get the transaction, e.g. "'insert into demo1 values('Dan');" ? I want the audittable like this:
Transaction | User | Date
-------------------------------------------------
Insert into demo1 values ('Dan') | Scott | 27-OCT-00
create or replace trigger audittrigger
after insert or delete or update on demo1
for each row
begin
if inserting
insert into audittable values('INSERT', user, sysdate);
elsif updating
insert into audittable values('UPDATE', user, sysdate);
elsif
insert into audittable values('DELETE', user, sysdate);
end if;
end;
/
Bookmarks