schedule job 调用存储过程 传递参数

我写的schedule job的脚本如下:

BEGIN
  SYS.DBMS_SCHEDULER.DROP_JOB
    (job_name  => 'POSP.JOB_R_TERM_DAY');
END;
/

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_JOB
    (
       job_name        => 'POSP.JOB_R_TERM_DAY'
      ,start_date      => TO_TIMESTAMP_TZ('2018/05/15 04:00:00.136818 PRC','yyyy/mm/dd hh24:mi:ss.ff tzr')
      ,repeat_interval => 'FREQ=DAILY; INTERVAL=1'
      ,end_date        => NULL
      ,job_class       => 'DEFAULT_JOB_CLASS'
      ,job_type        => 'STORED_PROCEDURE'
      ,job_action      => 'POSP.PROC_R_TERM_DAY'
      ,comments        => NULL
    );
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'RESTARTABLE'
     ,value     => FALSE);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'LOGGING_LEVEL'
     ,value     => SYS.DBMS_SCHEDULER.LOGGING_RUNS);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'MAX_FAILURES');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'MAX_RUNS');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'STOP_ON_WINDOW_CLOSE'
     ,value     => FALSE);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'JOB_PRIORITY'
     ,value     => 3);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'SCHEDULE_LIMIT');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'AUTO_DROP'
     ,value     => TRUE);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'POSP.JOB_R_TERM_DAY'
     ,attribute => 'number_of_arguments'
     ,value     => 2);

  SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
    ( job_name             => 'POSP.JOB_R_TERM_DAY'
     ,argument_position    => 1
     ,argument_value       => '20180508');

  SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
    ( job_name             => 'POSP.JOB_R_TERM_DAY'
     ,argument_position    => 2
     ,argument_value       => '');

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

SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
( name => ‘POSP.JOB_R_TERM_DAY’
,attribute => ‘number_of_arguments’
,value => 2);
number_of_arguments为传递参数的数量。

SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
( job_name => ‘POSP.JOB_R_TERM_DAY’
,argument_position => 1
,argument_value => ‘20180508’);
argument_position是添加的第几个参数,1代表第一个参数。
argument_value是添加参数的值。

你可能感兴趣的:(JOB)