Skip to Main Content

APEX

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!

ORA-00027: cannot kill current session

Er.RJMay 10 2017 — edited May 11 2017

HI,

database:oracle 11g

version:apex5

I am trying to kill the current session using DBMS_SCHEDULER,i have written code as below

Procedure:

create or replace procedure kill_session

as

user_id varchar2(4000);

system_id number;

sqlstate varchar2(4000);

schema_id varchar2(4000);

serial_number# number;

Begin

select osuser into user_id from v$session where audsid = userenv('sessionid');

select sid into system_id from v$session where audsid = userenv('sessionid');

select serial# into serial_number# from v$session where audsid = userenv('sessionid');

execute immediate  'alter system kill session '''||system_id||','||serial_number#||'''';

end;

/

DBMS_SCHEDULER job:

begin

DBMS_SCHEDULER.create_job (

job_name => 'kill',

job_type => 'PLSQL_BLOCK',

job_action=> 'kill_session;',

auto_drop => FALSE,

start_date => SYSTIMESTAMP,

enabled => TRUE,

repeat_interval => 'freq=minutely;INTERVAL=3');

end;

/

if i run the job, will get the error.

Run:

BEGIN

DBMS_SCHEDULER.RUN_JOB(

JOB_NAME => 'kill');

END;

Error:

ERROR at line 1:

ORA-00027: cannot kill current session

ORA-06512: at "SYS.KILL_SESSION", line 14

ORA-06512: at line 1

ORA-06512: at "SYS.DBMS_ISCHED", line 185

ORA-06512: at "SYS.DBMS_SCHEDULER", line 486

ORA-06512: at line 2

kindly guide me.Thank you.

This post has been answered by fac586 on May 10 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2017
Added on May 10 2017
8 comments
6,780 views