Use Case: We need to tracker number of users Or wanted to load CONTEXT, this is good way to achieve it.
May times issue we just wanted load some parameter for User or Login level, this is Handy trigger to do. Many level this trigger ca be used, Audit etc..
CREATE OR REPLACE TRIGGER trace_trigger
AFTER LOGON
ON DATABASE
DECLARE
sqlstr VARCHAR2(2000) := 'ALTER SESSION SET EVENTS ''10046 TRACE NAME CONTEXT FOREVER, LEVEL 4''';
BEGIN
IF (USER = 'SCOTT') THEN
execute immediate sqlstr;
--Direct immediate statements
EXECUTE IMMEDIATE 'ALTER SESSION SET TRACEFILE_IDENTIFIER = ''ENABLE_TRACE_DILIP''';
EXECUTE IMMEDIATE 'alter session set statistics_level=ALL';
EXECUTE IMMEDIATE 'alter session set max_dump_file_size=UNLIMITED';
EXECUTE IMMEDIATE 'alter session set events ''10046 trace name context forever, level 12''';
END IF;
END trace_trigger;
/
AFTER LOGON
ON DATABASE
DECLARE
sqlstr VARCHAR2(2000) := 'ALTER SESSION SET EVENTS ''10046 TRACE NAME CONTEXT FOREVER, LEVEL 4''';
BEGIN
IF (USER = 'SCOTT') THEN
execute immediate sqlstr;
--Direct immediate statements
EXECUTE IMMEDIATE 'ALTER SESSION SET TRACEFILE_IDENTIFIER = ''ENABLE_TRACE_DILIP''';
EXECUTE IMMEDIATE 'alter session set statistics_level=ALL';
EXECUTE IMMEDIATE 'alter session set max_dump_file_size=UNLIMITED';
EXECUTE IMMEDIATE 'alter session set events ''10046 trace name context forever, level 12''';
END IF;
END trace_trigger;
/
No comments:
Post a Comment