Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the blocking sql

yxes2013Aug 22 2013 — edited Aug 23 2013

Hi all,

I can display the sql_txt of the blocked sql using this:

select distinct s1.username ||'@'|| s1.machine ||'(INST=' || s1.inst_id ||' SID= '|| s1.sid ||')

is blocking '|| s2.username || '@' || s2.machine || ' (INST=' || s1.inst_id||' SID='||s2.sid ||')'    

AS blocking_status, s2.program,s3.sql_id, s3.sql_text from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2, v$sql s3

    where s1.sid=l1.sid

    and s2.sid=l2.sid

    and l1.block=1

    and l2.request >0

    and l1.id1=l2.id1

    and l2.id2=l2.id2

    and s2.sql_id = s3.sql_id;

But I can display the blocker sql

Can you help me how to get the blocking sql_txt?

I tried to revise the program which is:

select s1.sid,s1.serial#,s1.inst_id,s1.SQL_ID from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2, v$sql s3

    where s1.sid=l1.sid

    and s2.sid=l2.sid

    and l1.block=1

    and l2.request >0

    and l1.id1=l2.id1

    and l2.id2=l2.id2

    and s2.sql_id = s3.sql_id;

       SID    SERIAL#    INST_ID SQL_ID

       ---------- ---------- ---------- -------------

        88        148          1

But s1.sql_id is null. where do I get it?

Thanks

This post has been answered by Hemant K Chitale on Aug 23 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2013
Added on Aug 22 2013
33 comments
6,140 views