0% found this document useful (0 votes)
333 views6 pages

PLSQL Script To Find and Kill Blocking Sessions Objects

This PL/SQL script identifies blocking sessions in the database and kills them. It uses two cursors - one to identify sessions blocking on objects, and another to identify sessions that are blocking other sessions. For each blocking session found, it executes an ALTER SYSTEM statement to kill the session and commits the change. This helps resolve blocking issues and avoid potential deadlocks.

Uploaded by

versatile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
333 views6 pages

PLSQL Script To Find and Kill Blocking Sessions Objects

This PL/SQL script identifies blocking sessions in the database and kills them. It uses two cursors - one to identify sessions blocking on objects, and another to identify sessions that are blocking other sessions. For each blocking session found, it executes an ALTER SYSTEM statement to kill the session and commits the change. This helps resolve blocking issues and avoid potential deadlocks.

Uploaded by

versatile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

HOME

ABOUT ME: SHAILENDER THALLAM

CONTACT

ORACLE APPS INTERVIEW QUESTIONS

PL/SQL script to nd and Kill Blocking


Sessions/Objects

Search on this Site


Search

By Shailender Thallam | July 9, 2013 | 738 views | Category: AOL and SYSADMIN AOL SQL Scripts
0 Comments

Categories
Advanced Collections (2)
Alerts (2)
AOL and SYSADMIN (36)
AOL SQL Scripts (23)
APIs (7)

Business Events (3)

Costing (1)

PDFmyURL - online url to pdf conversion

Custom PLL (1)

Data Conversions/Interfaces (2)

Extensions (1)

General Ledger (2)

HRMS (5)
Interview Questions (10)
Inventory (7)
iRecruitment (1)
iStore (1)
OAF (8)

/*********************************************************
*PURPOSE: To findout blocking sessions and kill them
*
*AUTHOR: Shailender Thallam
*
**********************************************************/
-DECLARE
CURSOR c
IS
SELECT c.owner,
c.object_name,
c.object_type,
b.SID
,
b.serial#
,
b.status
,
b.osuser
,
b.machine
FROM v$locked_object a,
v$session b
,
dba_objects c
WHERE b.SID
= a.session_id
AND a.object_id = c.object_id
--AND b.osuser
= 'shailender.thallam'
--and c.object_name in ('JSW_CRM_C_HR_COIL_INFO','T_SPCL_BARCODE_CRS2')
;
-CURSOR d
IS
SELECT
SID,
PDFmyURL - online
url to
pdf conversion

OPM (4)
Oracle Apps Basics (20)
Oracle Learning Management (4)
Oracle SQL (18)
Order Management (15)
Payables (3)
Payments (6)
Personalizations (4)
PL/SQL (19)
Prole Options (6)
Purchasing (5)
Receivables (8)
Reports (2)
Scripts (8)

SELECT SID,
serial#
FROM v$session s
WHERE s.blocking_session IS NOT NULL
--AND osuser
= 'shailender.thallam';
-c_row c%ROWTYPE;
d_row d%ROWTYPE;
-l_sql VARCHAR2(100);
BEGIN
OPEN c;
LOOP
FETCH c INTO c_row;
EXIT
WHEN c%NOTFOUND;
dbms_output.put_line('in c '||c_row.SID);
l_sql := 'alter system kill session '''||c_row.SID||','||c_row.serial#||''''
EXECUTE IMMEDIATE l_sql;
COMMIT;
END LOOP;
CLOSE c;
---OPEN d;
LOOP
FETCH d INTO d_row;
EXIT
WHEN d%NOTFOUND;
dbms_output.put_line('in d '||d_row.SID);
l_sql := 'alter system kill session '''||d_row.SID||','||d_row.serial#||''''
EXECUTE IMMEDIATE l_sql;
COMMIT;
END LOOP;
CLOSE d;
END;
/
--

PDFmyURL - online url to pdf conversion

Security (1)
Shipping Execution (2)
Trade Mangement (1)
Uncategorized (2)
Unix / Shell Scripts (2)
WIP Jobs (1)
Workows (21)
XMLP (12)

For Further Reading

1. PL/SQL Script to Generate XML Tags for XMLP Report


2. Oracle Script to Copy Responsibilites of one user account to another user account
3. Oracle Script to Create User Login Account
4. PL/SQL Script to Submit a Concurrent Request from backend
Category: AOL and SYSADMIN AOL SQL Scripts

AdChoices

AdChoices

AdChoices

Oracle Database PL SQL

C Script

User Script

Bi Oracle

Program Script

Script Open

WOW! Did you like this post? We'll send more interesting posts like PL/SQL script to find and
Kill Blocking Sessions/Objects to you!
Enter your Email Address:
Enter your email address

Subscribe Me!

How to Display Leading Zeros in XMLP Report


PDFmyURL - online url to pdf conversion

How to get Concurrent Request ID of a parent

Excel Output

0 Comments
Recommend

program in a child program of a Request Set?

OracleAppsDNA

Sort by Oldest

Share

Start the discussion

Subscribe

Add Disqus to your site

PDFmyURL - online url to pdf conversion

Login

Privacy

What is BULK COLLECT?


How and Why do we...

Why cant we use


SQLERRM and...

SQL Query to remove


Non-Numeric...

Steps to Default a Sales


Order Attribute when t...

Frequently used Oracle


SQL Developer Short...

Basics of Business
Events and step by...

Developing XML
Publisher Reports...

How to get Concurrent


Request ID of a parent...

PDFmyURL - online url to pdf conversion

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy