I am trying to write a script that I could use to kill invalid sessions. This is what I got so far. There will be times when there are multiple invalid sessions. How do I put the sid and serial_num variables into the alter system statement?
declare
sid number(10,0);
serial_num number(10,0);
rec_cursor is
select sid, serial# from v$session a, sys.v_$locked_object b where
b.session_id = a.sid and b.xidsqn = 0;
begin
for rec in rec_cursor
loop
ALTER SYSTEM KILL SESSION 'sid,serial_number';
end loop;
end;
/
declare
sid number(10,0);
serial_num number(10,0);
rec_cursor is
select sid, serial# from v$session a, sys.v_$locked_object b where
b.session_id = a.sid and b.xidsqn = 0;
begin
for rec in rec_cursor
loop
ALTER SYSTEM KILL SESSION 'sid,serial_number';
end loop;
end;
/