Created
November 5, 2010 15:58
-
-
Save joesavak/664350 to your computer and use it in GitHub Desktop.
Easy Audit Trails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace trigger master_table_audit | |
after insert or update or delete on master_table | |
for each row | |
-- | |
begin | |
if UPDATING then | |
insert into audit_table ( | |
pk_uid | |
,edit_user | |
,edit_datetime | |
,trg_action | |
--additional audit columns | |
) values ( | |
:new.pk_uid | |
,:new.edit_user | |
,sysdate | |
,'UPDATE' | |
--additional audit columns | |
); | |
elsif DELETING then | |
insert into audit_table ( | |
edit_user | |
,edit_datetime | |
,pk_uid | |
,trg_action | |
--additional audit columns | |
) values ( | |
:old.edit_user | |
,sysdate | |
,:old.pk_uid | |
,'DELETE' | |
--additional audit columns | |
); | |
else | |
insert into audit_table ( | |
pk_uid | |
,edit_user | |
,edit_datetime | |
,trg_action | |
) values ( | |
:new.pk_uid | |
,:new.edit_user | |
,sysdate | |
,'INSERT' | |
--additional audit columns | |
); | |
end if; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment