Saturday, July 16, 2011

Know if any object is locked in current session

select session_id
, l.inst_id,substr(l.oracle_username,1,8) ora_user
, substr(l.session_id,1,3) sid
, s.serial#
, o.created
, substr(o.owner||'.'||o.object_name,1,40) object
, p.spid os_pid
, s.osuser
, s.machine
, s.module
, o.object_type
, s.terminal
, s.status
, s.process
, s.logon_time
, s.state
, decode(l.locked_mode,
         0,'NONE',
         1,'NULL',
         2,'ROW SHARE',
         3,'ROW EXCLUSIVE',
         4,'SHARE',
         5,'SHARE ROW EXCLUSIVE',
         6,'EXCLUSIVE',
         null) lock_mode
, fcr.request_id
, fcr.CONCURRENT_PROGRAM_ID
, fcp.CONCURRENT_PROGRAM_NAME
, fcpt.USER_CONCURRENT_PROGRAM_NAME
from sys.gv_$locked_object l
, dba_objects o
, sys.gv_$session s
, sys.gv_$process p
, fnd_concurrent_requests fcr
, fnd_concurrent_programs fcp
, fnd_concurrent_programs_tl fcpt
, v$session vs
where 1 = 1
--
and vs.PROCESS = fcr.OS_PROCESS_ID
and fcr.phase_code = 'R'
and fcp.CONCURRENT_PROGRAM_ID = fcr.CONCURRENT_PROGRAM_ID
and fcpt.CONCURRENT_PROGRAM_ID = fcp.CONCURRENT_PROGRAM_ID
and fcpt.LANGUAGE = 'US'
and vs.sid = l.SESSION_ID
and vs.sid = s.sid
--
and l.object_id = o.object_id
and l.inst_id = s.inst_id
and l.session_id = s.sid
and s.inst_id = p.inst_id
and s.paddr = p.addr(+)
--and o.object_name like '%OE_ORDER_LINES_ALL%'
--and session_id = 881 -- 1023--1023--1011
and s.module = :Conc_prog_short_name -- '%3041%'
order by l.inst_id ;
------------------

For error : ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired ORA-06512: at "APPS.WF_NOTIFICATION", line xxx ORA-06512: at line x
Appove Workflow Notification Mailer

select do.owner
        ,do.object_name
        ,do.object_type
        ,v.sid
        ,v.serial#
        ,v.program
        ,v.machine
        ,v.osuser
        ,v.service_name
        ,v.logon_time
        ,dl.lock_type
from dba_locks dl
       ,dba_objects do
       ,v$session v   
where do.object_name ='WF_NOTIFICATIONS'
   and do.object_type='TABLE'
   and dl.lock_id1 = do.object_id
   and v.sid = dl.session_id;

> ALTER SYSTEM KILL SESSION 'SID,SERIAL#';  --IMMEDIATE;
   COMMIT ;

No comments:

Post a Comment