11.2.0.3
desc killsessionlog
Name Null? Type
----------------------------------------------------- -------- --------------
KILLTIME NOT NULL DATE
USERNAME NOT NULL VARCHAR2(30)
SID NOT NULL NUMBER
SERIAL# NOT NULL NUMBER
CTIME NOT NULL NUMBER
MACHINE VARCHAR2(64)
TERMINAL VARCHAR2(30)
PROGRAM VARCHAR2(48)
ACTION VARCHAR2(64)
MODULE VARCHAR2(64)
want to test the code to kill the blocker
SQL> create or replace procedure killblocker
2 is
3 stmt varchar2(1000);
4 cursor c1 is
5 select s1.SQL_EXEC_START+l1.ctime killtime, s1.username,s1.sid,s1.serial#,l1.ctime ,s1.machine
,s1.TERMINAL, s1.PROGRAM,s1.ACTION,s1.MODULE
6 from v$lock l1, v$session s1, v$lock l2, v$session s2
7 where s1.sid=l1.sid and s2.sid=l2.sid
8 and l1.BLOCK=1 and l2.request > 0
9 and l1.id1 = l2.id1
10 and l2.id2 = l2.id2
11 and l1.ctime >0;
12 begin
13 for i in c1 loop
14 EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || i.sid || ',' || i.serial# || '''';
15 stmt := 'insert into killsessionlog values ('||i.killtime||','|| i.username||','||i.sid||','||i
.serial#||','||i.ctime||','||i.machine||','||i.TERMINAL||','|| i.PROGRAM||','||i.ACTION||','||i.MODU
LE||')'
16 ;
17 EXECUTE IMMEDIATE stmt;
18 dbms_output.put_line('SID '||i.sid ||' with serial# '||i.serial#||' was killed');
19 END LOOP;
20 END;
21 /
Procedure created.
created the blocker and blocked sessions.
SQL> exec killblocker
BEGIN killblocker; END;
*
ERROR at line 1:
ORA-00936: missing expression
ORA-06512: at "NN.KILLBLOCKER", line 17
ORA-06512: at line 1
the first EXECUTE IMMEDIATE for killing the session worked, but the 2nd EXECUTE IMMEDIATE for the insert failed as above. Not able to figure the problem.
TIA