调度程序未按预期工作

时间:2013-09-05 19:41:57

标签: stored-procedures oracle11g scheduled-tasks scheduler

我有一个简单的plsql过程,它只接受一个参数并完成一些工作。该过程本身将一些数据记录在日志记录表中,并在插入后提交,即过程开始,结束等。

程序签名是这些

pr_procedure_name(batch_size IN NUMBER DEFAULT 1000, poErrorDescription OUT VARCHAR)

这是我编写的用于运行此过程的scheduler / jb / program。理想情况下,我希望它每天都在23HRS运行但是为了测试我每15分钟运行一次。但它不起作用。有人可以帮忙解决错误吗

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_SCHEDULE
    (
      schedule_name    => 'CLEAN_EVERYDAY'
     ,start_date       => trunc(SYSDATE)
     ,repeat_interval  => /*'FREQ=DAILY; BYHOUR=23;'*/ 'freq=MINUTELY;interval=15;'
     ,end_date         => NULL
     ,comments         => 'Description goes here'
    );
END;
/

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_PROGRAM
    (
      program_name         => 'BATCH_CLEANUP'
     ,program_type         => 'PLSQL_BLOCK'
     ,program_action       => 'DECLARE
   nErrorCode   NUMBER;
   sErrorDesc   VARCHAR2 (32767);
BEGIN
    pr_procedure_name( poErrorDescription=>sErrorDesc ) ;

   IF (poErrorDescription IS NOT NULL)
   THEN
      RAISE_APPLICATION_ERROR (-20000, sErrorDesc);
   END IF;
END;'
     ,number_of_arguments  => 0
     ,enabled              => TRUE
     ,comments             => 'More comments'
    );
END;
/

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_JOB
    (
       job_name        => 'CLEAN_JB'
      ,schedule_name   => 'CLEAN_EVERYDAY'
      ,program_name    => 'BATCH_CLEANUP'
      ,comments        => NULL
    );
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'CLEAN_JB'
     ,attribute => 'RESTARTABLE'
     ,value     => TRUE);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'CLEAN_JB'
     ,attribute => 'LOGGING_LEVEL'
     ,value     => SYS.DBMS_SCHEDULER.LOGGING_RUNS);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'CLEAN_JB'
     ,attribute => 'MAX_FAILURES');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'CLEAN_JB'
     ,attribute => 'MAX_RUNS');
  BEGIN
    SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
      ( name      => 'CLEAN_JB'
       ,attribute => 'STOP_ON_WINDOW_CLOSE'
       ,value     => FALSE);
  EXCEPTION
    -- could fail if program is of type EXECUTABLE...
    WHEN OTHERS THEN
      NULL;
  END;
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'CLEAN_JB'
     ,attribute => 'JOB_PRIORITY'
     ,value     => 3);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'CLEAN_JB'
     ,attribute => 'SCHEDULE_LIMIT');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'CLEAN_JB'
     ,attribute => 'AUTO_DROP'
     ,value     => FALSE);

  SYS.DBMS_SCHEDULER.ENABLE
    (name                  => 'CLEAN_JB');
END;
/

0 个答案:

没有答案