Friday, March 9, 2012

Find the Query running for a Concurrent Program

Apps - Concurrent Program Query Finder

SELECT a.request_id, d.sid, d.serial#, a.requested_start_date
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
v$process c,
v$session d
--v$sql e
WHERE a.controlling_manager = b.concurrent_process_id
AND c.pid = b.oracle_process_id
AND d.paddr = c.addr
--AND d.sql_address = e.address
AND a.request_id = 87013699 --- request id of concurrent program
AND a.phase_code = 'R'

select s.inst_id,s.sid,s.serial#,p.spid,s.status,r.request_id
from gv$session s, gv$process p, apps.fnd_concurrent_requests r
where r.oracle_process_id=p.spid
and p.addr=s.paddr
and s.inst_id=p.inst_id
and r.request_id=743991966

select a.address
,      s.status
,      s.username
,      s.osuser
,      a.sql_text
,      s.sid
from v$sql a,    v$session s
where s.sql_address = a.address
and s.sid =2843 -- From Above query

select
a.sid, a.username,a.module, replace(a.machine,'.amazon.com') machine,c.spid ospid,decode (a.command
               , 0, '-    '
              , 1, 'CR TB'
               , 2, 'ISRT'
               , 3, 'SEL'
               , 4, 'CR CL'
               , 5, 'AL CL'
               , 6, 'UPDT'
               , 7, 'DEL'
               , 8, 'DR'
               , 9, 'CR IX'
               ,10, 'DR IX'
               ,11, 'AL IX'
               ,12, 'DR TB'
               ,15, 'AL TB'
               ,17, 'GRANT'
               ,18, 'REVOK'
               ,19, 'CRSYN'
               ,20, 'DRSYN'
               ,21, 'CR VW'
               ,22, 'DR VW'
               ,26, 'LK TB'
               ,27, 'NO OP'
               ,28, 'RENM'
               ,29, 'CMNT'
               ,30, 'AUDIT'
               ,31, 'NOAUD'
               ,32, 'CR DBL'
               ,33, 'DR DBL'
               ,34, 'CR DB'
               ,35, 'AL DB'
               ,36, 'CR RBS'
               ,37, 'AL RBS'
               ,38, 'DR RBS'
               ,39, 'CR TS'
               ,40, 'AL TS'
               ,41, 'DR TS'
               ,42, 'AL SES'
               ,43, 'AL USR'
               ,44, 'COMMIT'
               ,45, 'ROLLBK'
               ,46, 'SAVEPT'
               ,47, 'PL/SQL'
               ,62, 'AN TB'
               ,63, 'AN IX'
               ,64, 'AN CL'
               ,85, 'TR TB'
   ,    to_char(a.command)
               )                command
,nvl(a.sql_id,'-') sql_id,a.sql_child_number, w.event,nvl(to_char(a.blocking_session,999999),'     -') blocking_session,a.blocking_instance blocking_instance, round(a.last_call_et/60,0) "last_etM",nvl(to_char(round(((b.blocks*p.value)/1024/1024),2),999999),'      -') size_mb
from v$session a, (select session_addr,sum(blocks) blocks from v$sort_usage group by session_addr) b, v$process c, v$parameter p, v$session_wait w
where p.name='db_block_size' and a.saddr = b.session_addr(+) and a.sid=w.sid(+)
and a.paddr=c.addr  and a.status='ACTIVE' and a.username is not null and a.sid='&sid'
order by a.sql_id,a.username,a.sql_id,a.sql_child_number


select
a.sid,
a.serial#,
b.sql_text
from
v$session a,
v$sqlarea b
where
a.sql_address=b.address
and
sid=43;

SELECT nvl(ses.username,'ORACLE PROC')||' ('||ses.sid||')' USERNAME,sql.sql_id,
           SID,   
           MACHINE, 
           REPLACE(SQL.SQL_TEXT,CHR(10),'') STMT, 
          ltrim(to_char(floor(SES.LAST_CALL_ET/3600), '09')) || ':'
           || ltrim(to_char(floor(mod(SES.LAST_CALL_ET, 3600)/60), '09')) || ':'
           || ltrim(to_char(mod(SES.LAST_CALL_ET, 60), '09'))    RUNT 
      FROM gV$SESSION SES,   
           gV$SQLtext_with_newlines SQL 
     where SES.STATUS = 'ACTIVE'
       and SES.USERNAME is not null
       and SES.SQL_ADDRESS    = SQL.ADDRESS 
       and SES.SQL_HASH_VALUE = SQL.HASH_VALUE 
       AND SES.AUDSID <> USERENV('SESSIONID') 
       AND SES.AUDSID = (select oracle_session_id from apps.fnd_concurrent_requests where request_id='771831089')
     order by runt desc, 1,sql.piece


1 comment: