Some sites require the database to track the last user’s changes to a database table. Others will require the database to log all changes to the table. These tasks are best accomplished by one or more triggers on the database table. In this way, changes made by applications other than ARCHIBUS or changes made from ARCHIBUS Web Central are also appropriately logged. Below are the steps for establishing these two triggers.
Note -- To use these triggers, your site must implement database-level security; that is, your users must log into the database with the user name that you would like included in your log.
To establish last change or insertion logging on a table, complete the following steps.
modified_on_date
modified_by_username
Last_Update.sp
create or replace trigger last_update
after update on bl
for each row
begin
:new.modified_on_date := sysdate;
:new.modified_by_username := user;
end;
/
Last_Ins.sp
create or replace trigger last_insert
after insert on bl
for each row
begin
:new.modified_on_date := sysdate;
:new.modified_by_username := user;
end;
/
To establish a running log on all tables:
modified_by_username
modified_on_date
modified_at_time
modification_type
One way to do so is to use the create_log.sql script provided below.
create table
audit_log
(table_name char(64) not null,
modified_by_username char(64) not null,
modified_on_date date not null,
modified_at_time time not null,
modification_type char(16) null );
create or replace
trigger change_log
after insert or update or delete on bl
for each row
begin
insert into audit_log (table_name, modified_by_username, modified_on_date)
select "bl", user, sysdate from dual;
end;
/