How to Identify Blocking Sessions

Posted on
Here I introduce a sample of PL/SQL code to monitor the blocking sessions every N minutes and output in a formatted report.First of all, edit the sql script.[oracle@primary01 ~]$ vi CheckBlockingSessions.sqlSET SERVEROUTPUT ON;ALTER SESSION SET NLS_DATE_FORMAT=’YYYY-MM-DD HH24:MI:SS’;DECLARE  V_MAX_COUNT NUMBER := 4;  V_WAIT_MIN  NUMBER := 5;  CURSOR C_BLOCKING  IS    SELECT BLOCKER.INST_ID,      BLOCKER.SID BLOCKER_SID […]