by 달빛하늘아래 [Oracle Admin] DBMS_JOB DBMS_SCHEDULER [2013.07.29 13:47:04]
하기와 같은 DBMS_JOB을 DBMS_SCHEDULER로 변환시 계속 문제가 생겨 문의 드립니다.
- DBMS_SCHEDULER , DBMS_JOBS, DBMS_PROGRAM의 개념을 잘 이해 못하겠습니다.
답답한 마음에 문의 드려 봅니다.
- TEST 계정에서 생성
- PARTTN_MAANGE PACKAGAE의 MAIN PROCEDURE 실행
- 해당 PROCEDURE의 3개의 ARGUMENT 값을 입력
- 총 3개의 JOB을 등록하여 실행
□ DBMS_JOB 실행 구문
DECLARE
X NUMBER;
BEGIN
TEST.DBMS_JOB.SUBMIT
( job => X
,what => 'TEST.PKG_PARTTN_MANAGE.MAIN(''TEST'', ''MONTH'', ''PARTITION'');
PJT_ADMIN.PKG_PARTTN_MANAGE.MAIN(''TEST'', ''DAY'', ''PARTITION'');
PJT_ADMIN.PKG_PARTTN_MANAGE.MAIN(''TEST'', ''HOUR'', ''PARTITION'');'
,next_date => to_date('10/05/2013 09:00:00','dd/mm/yyyy hh24:mi:ss')
,interval => 'TRUNC(SYSDATE+1) + 9/24'
,no_parse => FALSE
);
TEST.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
/
□ DBMS_SCHEDULE로의 변환
1) DBMS_SCHEDULER
BEGIN
dbms_scheduler.create_schedule
(
schedule_name => 'TEST.PARTTN_MANAGE_SCHEDULE',
start_date => systimestamp,
end_date => null,
repeat_interval => 'freq=daily;byhour=10;byminute=0;bysecond=0;',
comments => 'Day at 10:00 AM'
);
END;
2) DBMS_JOB
BEGIN
dbms_scheduler.create_job(
job_name => 'PARTTN_MANAGE_JOB1'
, program_name =>'PARTTN_MANAGE_SCHEDULE'
, schedule_name =>'PARTTN_MANAGE_PGM'
, enabled => FALSE
, comments => 'Partition for job schedule');
BEGIN;
3) DBMS_PROGRAM
- > 현재 DBMS_JOB 하나만 PROGRAM으로 만들었는데 나머지 2개의 JOB을 등록하려면 어떻게 해야 하는지?
BEGIN
TEST.DBMS_SCHEDULER.CREATE_PROGRAM
(
program_name => 'TEST.PARTTN_MANAGE_PGM'
,program_type => 'STORED_PROCEDURE'
,program_action => 'TEST.PKG_PARTTN_MANAGE.MAIN'
,number_of_arguments => 3
,enabled => FALSE
,comments => 'Create Partition for job schedule.'
);
TEST.DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT
(
program_name => TEST.PARTTN_MANAGE_PGM''
,argument_name => 'ESIMAX16'
,argument_position => 1
,argument_type => 'VARCHAR2'
,default_value => ''
);
TESTDBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT
(
program_name => TEST.PARTTN_MANAGE_PGM
,argument_name => 'MONTH'
,argument_position => 2
,argument_type => 'VARCHAR2'
,default_value => ''
);
TEST.DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT
(
program_name => TEST.PARTTN_MANAGE_PGM
,argument_name => 'PARTITION'
,argument_position => 3
,argument_type => 'VARCHAR2'
,default_value => ''
);
TEST.DBMS_SCHEDULER.ENABLE
(name => 'TEST.PARTTN_MANAGE_PGM');
END;