KILL sniped sessions dynamic sql


grant select on v_$session to portal;

Create procedure 
CREATE OR REPLACE PROCEDURE KILL_SNIPED_SESSION AS
COM VARCHAR2(200);
cursor c1 is select SID,SERIAL# from v$session where status='SNIPED';

BEGIN

FOR V1 IN C1 LOOP

COM:= 'ALTER SYSTEM kill session '''||V1.SID||','||V1.SERIAL#||''' immediate';

DBMS_OUTPUT.PUT_LINE (COM);

EXECUTE IMMEDIATE COM ;

END LOOP;

 END;
/

Schedule the job

DECLARE

   JOB NUMBER;

   BEGIN

   DBMS_JOB.SUBMIT(JOB,'PORTALPAY.KILL_SNIPED_SESSION;',SYSDATE,'SYSDATE+6/24');

  END;

/

Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post