Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Procedure for Killing sessions

Shaan_dmpJun 25 2012 — edited Jun 25 2012
Hi All,

Almost everyday we have requirement to kill user sessions for dev user, I'm thinking to create a procedure for this and grant to the users so that they can kill it by themself.


Below is the what I got from Ask Tom forum, however appreciate if someone can share few information if already imlemented in there environment


<quote>
create or replace procedure kill_session( p_sid in number,
p_serial# in number)
is
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
execute immediate '
alter system kill session ''' ||
to_char(p_sid,'999999')||','||
to_char(p_serial#,'999999')||'''';
else
raise_application_error( -20001,
'You do not own session ''' ||
p_sid || ',' || p_serial# ||
'''' );
end if;
END;/


grant execute on kill_session to <username>
</quote>

Regards,

shaan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 23 2012
Added on Jun 25 2012
8 comments
618 views