Saturday, April 2, 2016

Some useful scripts.


1) Running programs, user names

/* Script to show the running programs,username and time */
SELECT   q.concurrent_queue_name || ' - ' || target_node qname,
         a.request_id "Req Id", fu.user_name, a.phase_code, a.status_code,
           (NVL (actual_completion_date, SYSDATE) - actual_start_date
           )
         * 1440 "Time",
            c.concurrent_program_name
         || ' ('
         || TO_CHAR (c.concurrent_program_id)
         || ')' intprog,
         ctl.user_concurrent_program_name "program"
    FROM applsys.fnd_concurrent_requests a,
         applsys.fnd_concurrent_processes b,
         applsys.fnd_concurrent_queues q,
         applsys.fnd_concurrent_programs c,
         applsys.fnd_concurrent_programs_tl ctl,
         applsys.fnd_user fu
   WHERE a.controlling_manager = b.concurrent_process_id
     AND a.concurrent_program_id = c.concurrent_program_id
     AND a.program_application_id = c.application_id
     AND a.status_code IN ('I', 'H', 'W', 'Q', 'R', 'F')
     AND a.phase_code IN ('P', 'R')
     AND b.queue_application_id = q.application_id
     AND b.concurrent_queue_id = q.concurrent_queue_id
     AND ctl.concurrent_program_id = c.concurrent_program_id
     AND ctl.LANGUAGE = 'US'
     AND fu.user_id = a.requested_by
ORDER BY 6 DESC;


2) Request id to Trace file name


/* Request id to Trace file name*/

SELECT 'Request id: ' || request_id, 'Trace id: ' || oracle_process_id,
       'Trace Flag: ' || req.enable_trace,
          'Trace Name: 
'
       || dest.VALUE
       || '/'
       || LOWER (dbnm.VALUE)
       || '_ora_'
       || oracle_process_id
       || '.trc',
       'Prog. Name: ' || prog.user_concurrent_program_name,
       'File Name: ' || execname.execution_file_name
       || execname.subroutine_name,
          'Status : '
       || DECODE (phase_code, 'R', 'Running')
       || '-'
       || DECODE (status_code, 'R', 'Normal'),
       'SID Serial: ' || ses.SID || ',' || ses.serial#,
       'Module : ' || ses.module
  FROM fnd_concurrent_requests req,
       v$session ses,
       v$process proc,
       v$parameter dest,
       v$parameter dbnm,
       fnd_concurrent_programs_vl prog,
       fnd_executables execname
 WHERE req.request_id = &request
   AND req.oracle_process_id = proc.spid(+)
   AND proc.addr = ses.paddr(+)
   AND dest.NAME = 'user_dump_dest'
   AND dbnm.NAME = 'db_name'
   AND req.concurrent_program_id = prog.concurrent_program_id
   AND req.program_application_id = prog.application_id
   AND prog.application_id = execname.application_id
   AND prog.executable_id = execname.executable_id;

~~ Cheer
s

No comments :

Post a Comment