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.