André Spadini | MultiCloud | DBA

André Spadini | MultiCloud | DBA

Oracle: Trigger Tracer Logon

Oracle: Trigger Tracer Logon

Subscribe to my newsletter and never miss my upcoming articles

Segue abaixo uma trigger para ajudar a gerar tracer de um determinado usuário na hora do Logon.

create or replace TRIGGER USER_TRACE_TRG AFTER LOGON ON DATABASE
declare
SI int;
SE int;
FILE_NAME varchar2(200);
begin
IF USER = 'USERNAME' ---- Give the user name here
THEN
select sid,serial# into SI,SE from v$session where audsid = userenv('SESSIONID');
FILE_NAME:='TRACE_ASPADINI_'||SI||'_'||SE;
execute immediate 'ALTER SESSION SET tracefile_identifier = '||FILE_NAME;
execute immediate 'alter session set sql_trace = true';
execute immediate 'ALTER SESSION SET EVENTS ''10046 trace name context forever, level 12''';
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
end;
 
Share this