开发者

Is it possible to create a job from within a DBMS_SCHEDULER job?

开发者 https://www.devze.com 2023-04-10 06:04 出处:网络
Creating a job from within a job using DBMS_JOB throws an: ORA-32317: canno开发者_运维知识库t run a job from a job

Creating a job from within a job using DBMS_JOB throws an:

ORA-32317: canno开发者_运维知识库t run a job from a job

Does anyone know if this restriction has been lifted in DBMS_SCHEDULER?


Yes you can:

DECLARE
BEGIN
  dbms_scheduler.create_job  
 (job_name => 'TEST1',  
  job_type=> 'PLSQL_BLOCK',
  job_action=>'BEGIN dbms_scheduler.create_job  
              (job_name => ''TEST2'',  
               job_type=> ''PLSQL_BLOCK'',
               job_action=>''DECLARE v_result NUMBER; BEGIN SELECT 1 INTO v_result FROM dual; END;'',  
               start_date=>SYSDATE,
               repeat_interval=>''FREQ=DAILY'',
               end_date=>SYSDATE+1,
               enabled=>true,  
               auto_drop=>false,  
               comments=>''Job submitted FROM a job''); end;',  
  start_date=>SYSDATE,
  repeat_interval=>'FREQ=DAILY',
  end_date=>SYSDATE+1,
  enabled=>true,  
  auto_drop=>false,  
  comments=>'Job to submit a job');  
END;  

This demonstrates the concept. You could call a procedure instead of an inline PL/SQL block to do your job submittal. Clearly you can adjust any or all of the parameters to the create_job procedure. I would guess you could spawn a job that spawns yet another job.

0

精彩评论

暂无评论...
验证码 换一张
取 消