Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
connect system/<password>@<instance TNS alias>
create table auditor
(table_name varchar(30)
,action_datetime date
,perpetrator varchar(200)
,action_type varchar(10)
,pk varchar(100)
,which_column varchar(30)
,old_value varchar(4000)
,new_value varchar(4000)
)
/
grant select, insert on auditor to public;
REM **************************************************************
REM David L. Hunt (file author) distributes this and other
REM files/scripts for educational purposes only, to illustrate the
REM use or application of various computing techniques. Neither the
REM author nor Dasages, LLC, makes any warranty regarding this
REM script's fitness for any industrial application or purpose nor is
REM there any claim that this or any similarly-distributed scripts
REM are error free or should be used for any purpose other than
REM illustration.
REM **************************************************************
connect system/<password>@<instance TNS alias>
create or replace view system.sessions as select * from sys.v_$session;
grant select on system.sessions to public;
Create or Replace procedure system.generic_audit
(table_name in varchar2,
action_type in varchar2,
updated_column in varchar2,
pk in varchar2,
old_value in varchar2,
new_value in varchar2)
is
userinfo varchar2(200);
begin
IF (old_value is null and new_value is not null) or
(old_value is not null and new_value is null) or
(old_value <> new_value) THEN
select osuser||' on '||machine||'(as '||user||')' into userinfo
from system.sessions where audsid = userenv('sessionid');
INSERT INTO system.auditor
VALUES (table_name, SYSDATE,USERINFO,action_type,
pk,updated_column,old_value,new_value);
END IF;
END;
/
GRANT execute on generic_audit to public;
Create or Replace TRIGGER audit_s_emp_changes
Before insert or update or delete on test.s_emp FOR EACH ROW
BEGIN
if inserting then
generic_audit('test.s_emp','INSERT','All columns',:new.id,'inserting','INSERTING');
elsif deleting then
generic_audit('test.s_emp','DELETE','All columns',:old.id,'deleting','DELETING');
else
generic_audit('test.s_emp','UPDATE','LAST_NAME',:old.id,:old.last_name,:new.last_name);
generic_audit('test.s_emp','UPDATE','FIRST_NAME',:old.id,:old.FIRST_name,:new.FIRST_name);
generic_audit('test.s_emp','UPDATE','SALARY',:old.id,:old.SALARY,:new.SALARY);
end if;
end;
/