0

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

程序签名是这些

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

这是我为运行此过程而编写的调度程序/jb/程序。理想情况下,我希望它每天在 23 小时运行,但为了测试,我每 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;
/
4

0 回答 0