Wednesday, 15 February 2017

Start/Stop the trace for all the oracle sessions specific to the database user .


Start the oracle trace

declare
my_sid       V$SESSION.SID%type;
my_serial_no V$SESSION.SERIAL#%type;
begin
for a in (
            select SID
            from   V$SESSION
            where  USERNAME = 'username'
         )
loop
   select SID, SERIAL#
   into   my_sid, my_serial_no
   from   V$SESSION
   where  SID = a.SID;

   dbms_output.put_line('sid: '||my_sid);
   dbms_support.start_trace_in_session(my_sid,my_serial_no,true,true);
  
end loop;
end;
/

Stop the oracle trace

declare
my_sid       V$SESSION.SID%type;
my_serial_no V$SESSION.SERIAL#%type;
begin
for a in (
            select SID
            from   V$SESSION
            where  USERNAME = 'username'
         )
loop
   select SID, SERIAL#
   into   my_sid, my_serial_no
   from   V$SESSION
   where  SID = a.SID;

   dbms_output.put_line('sid: '||my_sid);
    dbms_support.stop_trace_in_session(my_sid,my_serial_no);
  
end loop;
end;

/

No comments:

Post a Comment