PL/SQL (MOSC)

MOSC Banner

Newbie trying to kill sessions using a Procedure...

edited Mar 1, 2012 7:58PM in PL/SQL (MOSC) 14 commentsAnswered ✓
version 11.2.0.2
I found this on ASKTOM:

CREATE OR REPLACE procedure SYS.kill_session( p_sid in varchar2,
                                          p_serial# in varchar2)
is
    cursor_name     pls_integer default dbms_sql.open_cursor;
    ignore          pls_integer;
BEGIN
    select count(*) into ignore
      from V$session
     where username = USER
       and sid = p_sid
       and serial# = p_serial# ;

    if ( ignore = 1 )
    then
        dbms_sql.parse(cursor_name,
                      'alter system kill session '''
                                ||p_sid||','||p_serial#||'''',
                       dbms_sql.native);
        ignore := dbms_sql.execute(cursor_name);
    else
        raise_application_error( -20001,
                               'You do not own session ''' ||
                                p_sid || ',' || p_serial# ||
                               '''' );

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center