Using trigger to audit delete on a table

create or replace trigger a_trigger
before delete on a

declare
username varchar2(20);
ipaddress varchar2(20);
sessionuser varchar2(20);
begin

SELECT sys_context(‘USERENV’,’OS_USER’) into username FROM dual;

SELECT sys_context(‘USERENV’,’IP_ADDRESS’) into ipaddress FROM dual;

SELECT sys_context(‘USERENV’,’SESSION_USER’) into sessionuser from dual;

insert a_delete_history (trigger_time,os_username,sess_username,ip_address) values (sysdate,username,sessionuser,ipaddress);

end a_trigger;

Advertisements

About Alex Zeng
I would be very happy if this blog can help you. I appreciate every honest comments. Please forgive me if I'm too busy to reply your comments in time.

One Response to Using trigger to audit delete on a table

  1. neworacledba says:

    statement level audit is a great post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: