急!!!怎样在pl/sql developer中给oracle添加一个调度作业?在线等.....
急!!!怎样在pl/sql developer中给oracle添加一个调度作业?
------解决方案-------------------- SQL> create table a(a date);
Table created
创建一个过程
create or replace procedure kill_inactivate_SESSION is
cursor cur_session is
select s.sid, s.serial#
from v$session s, v$session_wait sw
where s.sid = sw.sid
and s.status = 'INACTIVE '
--and s.username in (select user_name from gusermgr.gbs_user_tbl)
and s.last_call_et > = 3600
and sw.event = 'SQL*Net message from client ';
v_sid v$session.sid%type;
v_serial v$session.serial#%type;
v_sqlstr varchar2(63);
v_errmsg varchar2(63);
begin
v_sqlstr := 'alter system kill session ' ' ';
v_errmsg := 'is killed because it is INACTIVE for longer than 1 hour. ';
open cur_session;
loop
fetch cur_session into v_sid, v_serial;
exit when cur_session%NOTFOUND;
execute immediate v_sqlstr||v_sid|| ', '||v_serial|| ' ' ' ';
DBMS_OUTPUT.PUT_LINE( 'SESSION( '||v_sid|| ', '||v_serial|| ') '||v_errmsg);
end loop;
close cur_session;
return;
end kill_inactivate_SESSION;
Procedure created
提交作业
SQL> variable n number;
SQL> begin
2 dbms_job.submit(:n, 'kill_inactivate_session; ',sysdate, 'sysdate+1 ');
3 commit;
4 end;
5 /
PL/SQL procedure successfully completed
n
---------
514
示例如上
------解决方案--------------------begin
sys.dbms_job.submit(job => :job,
what => 'MYPROC; ',
next_date => to_date( '17-01-2007 00:00:00 ', 'dd-mm-yyyy hh24:mi:ss '),
'TRUNC(SYSDATE + 1) ');
commit;
end;
/