Thursday, April 9, 2009

SQL suery to find out all errored requests

Use this SQL script to find out all the requests that ended in ERROR, TERMINATED or WARNING state.

===================================================
-- --------------------------------------------------
-- Author : New Generation Consultants
-- Script to find erroring requests
-- --------------------------------------------------
clear columns
set pages 23
set lines 500
col os form A6
col program head "Program Name" form A45 trunc
col shrtnm head "Shortname" format a13
col time head Elapsed form 9999.99
col request_id head "Req Id" form 9999999
col cprogid head "Prg Id" form 999999
col "Started On" format a10
col "Finished On" format a11
col "Submitted By" format a35 trunc
col argument_text head "Arguments" format a50 trunc
col statustxt head Status format a12 trunc
col phasetxt head Phase format a10 trunc
set recsep wrap
set verify off
select a.request_id
,c.concurrent_program_name shrtnm
,c.concurrent_program_id cprogid
,ctl.user_concurrent_program_name "program"
,l2.meaning phasetxt
,l1.meaning statustxt
--,to_char(a.actual_start_date,'hh:mi:ssAM') "Started On"
--,to_char(a.actual_completion_date,'hh:mi:ssAM') "Finished On"
,(nvl(actual_completion_date,sysdate)-actual_start_date)*1440 "Time"
--,a.argument_text
,u.user_name ' - ' u.description "Submitted By"
from fnd_Concurrent_requests a,fnd_concurrent_programs c,fnd_concurrent_programs_tl ctl
,fnd_user u,
(select l1.lookup_code,l1.meaning from fnd_lookup_values l1
where l1.lookup_type = 'CP_STATUS_CODE'
and l1.language = 'US'
and l1.enabled_flag = 'Y'
and (l1.start_date_active <= sysdate AND l1.start_date_active IS NOT NULL)
and (l1.end_date_active > sysdate or l1.end_date_active is null
and l1.meaning in ('Terminated','Warning','Cancelled','Error'))) l1,
(select l2.lookup_code,l2.meaning from fnd_lookup_values l2
where l2.lookup_type = 'CP_PHASE_CODE'
and l2.language = 'US'
and l2.enabled_flag = 'Y'
and (l2.start_date_active <= sysdate AND l2.start_date_active IS NOT NULL)
and (l2.end_date_active > sysdate or l2.end_date_active is null)
and l2.meaning = 'Completed')l2
where trunc(a.actual_start_date) = trunc(sysdate) and a.program_application_id = c.application_id
and a.concurrent_program_id = c.concurrent_program_id and ctl.application_id = c.application_id
and ctl.concurrent_program_id = c.concurrent_program_id
and l1.lookup_code = a.status_code
and l2.lookup_code = a.phase_code
and u.user_id = a.requested_by
order by actual_start_date

===================================================

1 comment:

Unknown said...

thanks. I know another way of sp-sql-database-recovery, maybe you will be interested