scheduler_job管理
--查询所有scheduler_job
SELECT job_name,
job_type,
job_action,
to_char(start_date,
'yyyy-mm-dd hh24:mi:ss'),
repeat_interval,
enabled,
state
FROM dba_scheduler_jobs;
--创建scheduler_job
create procedure p_test
as
begin
dbms_output.put_line('This is a procedure test !');
end;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'testjob',
job_type => 'STORED_PROCEDURE',
job_action => 'P_TEST',
enabled => true,
start_date => sysdate+6/24,
repeat_interval => 'FREQ=DAILY;INTERVAL=1');
END;
/
--启用/禁用scheduler_job
exec dbms_scheduler.enable('testjob');
exec dbms_scheduler.disenable('testjob');
--匿名块
exec dbms_scheduler.set_attribute('testjob','job_type','PLSQL_BLOCK');
--存储过程
exec dbms_scheduler.set_attribute('APTS.DAILY_JOB','JOB_TYPE','STORED_PROCEDURE');
--运行scheduler_job
exec dbms_scheduler.run_job('testjob');
--删除scheduler_job
exec dbms_scheduler.drop_job('testjob');
阅读(2415) | 评论(0) | 转发(0) |