日期:2014-05-16 浏览次数:20553 次
-- CREATED ON 2012/5/28 BY WANGHUI ---动态创建并行JOB DECLARE -- LOCAL VARIABLES HERE V_JOB_NAME VARCHAR2(20); BEGIN -- TEST STATEMENTS HERE FOR C IN (SELECT * FROM LATN_AREA_INFO WHERE LATN_ID <> -1) LOOP BEGIN V_JOB_NAME := 'JOB_SERV_' || C.LATN_ID; ---删除已有JOB FOR REC IN (SELECT * FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = V_JOB_NAME) LOOP SYS.DBMS_SCHEDULER.DROP_JOB(REC.JOB_NAME); END LOOP; ---动态创建新JOB SYS.DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => V_JOB_NAME, JOB_TYPE => 'STORED_PROCEDURE', JOB_ACTION => 'PRO_DAY_USER', NUMBER_OF_ARGUMENTS => 1, SCHEDULE_NAME => 'DAY_SCHEDULE', JOB_CLASS => 'DEFAULT_JOB_CLASS', ENABLED => FALSE, AUTO_DROP => TRUE, COMMENTS => ''); SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(JOB_NAME => V_JOB_NAME, ARGUMENT_POSITION => 1, ARGUMENT_VALUE => C.LATN_ID); SYS.DBMS_SCHEDULER.RUN_JOB(V_JOB_NAME); END; END LOOP; END;