How to Generate a Trace file in Oracle Reports

Trace enable RDF Report

function BeforeReport return boolean is
  CURSOR c_program_id(p_request_id IN NUMBER) IS
SELECT concurrent_program_id, nvl(enable_trace,'N')
FROM   FND_CONCURRENT_REQUESTS
WHERE  REQUEST_ID = p_request_id;
   
CURSOR get_audsid IS
SELECT a.sid, a.serial#, b.spid FROM v$session a,v$process b
WHERE audsid = userenv('SESSIONID')
AND a.paddr = b.addr;
 
CURSOR get_dbname IS
SELECT name FROM v$database;    

v_enable_trace    FND_CONCURRENT_PROGRAMS.enable_trace%TYPE;
v_program_id      FND_CONCURRENT_PROGRAMS.concurrent_program_id%TYPE;
v_audsid NUMBER := userenv('SESSIONID');
v_sid NUMBER;
v_serial NUMBER;
v_spid VARCHAR2(9);
v_dbname VARCHAR2(25);
begin
   SRW.USER_EXIT('FND SRWINIT');
  SRW.MESSAGE( 1275, 'Report Version is 120.3 Last modified date is 02/09/2005');
-------------------------------------------Trace File Generation Code---------------------------------------------------------------------------
BEGIN
   OPEN c_program_id(:p_conc_request_id);
    FETCH c_program_id INTO v_program_id, v_enable_trace;
    CLOSE c_program_id;

    SRW.message( 1275, 'v_program_id -> '||v_program_id
            ||', v_enable_trace -> '||v_enable_trace
            ||', request_id -> '||:P_CONC_REQUEST_ID);
    IF v_enable_trace = 'Y' THEN
   
    OPEN get_audsid;
  FETCH get_audsid INTO v_sid, v_serial, v_spid;
  CLOSE get_audsid;
 
  OPEN get_dbname;
  FETCH get_dbname INTO v_dbname;
  CLOSE get_dbname;
 
  srw.message(1275,'TraceFile Name = '||lower(v_dbname)||'_ora_'||v_spid||'.trc');
 
  SRW.DO_SQL('ALTER SESSION SET EVENTS ''10046 trace name context forever, level 4''');
    END IF; --Enable Trace
    return (true);
   EXCEPTION
      WHEN OTHERS THEN
          SRW.MESSAGE( 1275, 'Error during enabling the trace. ErrCode -> '||SQLCODE ||', ErrMesg -> '||SQLERRM );
   END;
end;

Best Sellers in Video Games