Hi All,
I want to know every details that whenever someone performs a DML in schema A on any tables to logged into a table.
I have attempted these:
-Create log table
CREATE TABLE audit_rst(
user_id VARCHAR2(30),
session_id NUMBER,
host varchar2(30),
ip_add varchar2(30),
action CHAR(3),
date_executed DATE);
--Create a row based trigger for every tabel available
--this exampel shows only one table
CREATE OR REPLACE TRIGGER AUDIT_cc_2008
AFTER INSERT OR DELETE OR UPDATE ON cc_2008 FOR EACH ROW
DECLARE
v_operation VARCHAR2(10) := NULL;
BEGIN
IF INSERTING THEN
v_operation := 'I';
ELSIF UPDATING THEN
v_operation := 'U';
ELSE
v_operation := 'D';
END IF;
IF INSERTING OR UPDATING THEN
INSERT INTO audit_rst(
USER_ID,
SESSION_ID,
HOST,
ACTION,
DATE_EXECUTED)
VALUES (
user,
sys_context('USERENV','SESSIONID'),
sys_context('USERENV','HOST'),
SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15)
v_operation, SYSDATE);
ELSE
INSERT INTO audit_rst (
USER_ID,
SESSION_ID,
HOST,
ACTION,
DATE_EXECUTED)
VALUES (
user,
sys_context('USERENV','SESSIONID'),
sys_context('USERENV','HOST'),
v_operation, SYSDATE);
END IF;
END;
Do I need to create this trigger for every table available in teh schema...or is tehre a schema level trigger that can scan through the schema and pick up any dml changes to any table and log it into teh audit_rst table?