/*
  This script will set the SQL Trace on in passed SID.
*/

-- alter session set events '10053 trace name context forever, level 12';
-- alter session set events '10053 trace name context off';

BEGIN
   FOR i IN ( SELECT SID, serial#
               FROM v$session
              WHERE SID = &&1 )
   LOOP
      /* Set session DUMP file size */ 
      SYS.dbms_system.set_int_param_in_session ( i.SID
                                               , i.serial#
                                               , 'MAX_DUMP_FILE_SIZE'
                                               , 2097152                -- operating system blocks
                                               );
      /* Set session TIMED_STATISTICS to TRUE */ 
      SYS.dbms_system.set_bool_param_in_session ( i.SID
                                                , i.serial#
                                                , 'TIMED_STATISTICS'
                                                , TRUE
                                                );
      /* Set session trace level to 12 */ 
      dbms_system.set_ev ( i.SID
                         , i.serial#
                         , 10053
                         , 12
                         , ''
                         );

      /* Set session SQL trace to TRUE */ 
      dbms_system.set_sql_trace_in_session ( i.SID
                                           , i.serial#
                                           , TRUE
                                           );
   END LOOP;
END;
/
