schedule job 呼叫儲存過程 傳遞引數
阿新 • • 發佈:2019-01-10
我寫的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是新增引數的值。