@drop t
create table t ( x date, y int );
create or replace procedure proc1 is begin
insert into t values (sysdate,1);
commit;
end;
/
create or replace procedure proc2 is begin
insert into t values (sysdate,2);
commit;
end;
/
begin
dbms_scheduler.create_program (
program_name => 'PROG_1',
program_type => 'PLSQL_BLOCK',
program_action => 'proc1;',
enabled => true);
end;
/
begin
dbms_scheduler.create_program (
program_name => 'PROG_2',
program_type => 'PLSQL_BLOCK',
program_action => 'proc2;',
enabled => true);
end;
/
exec dbms_scheduler.create_chain (chain_name=>'MY_CHAIN')
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP1','PROG_1');
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP2','PROG_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','TRUE','START "STEP1"','RULE_1');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','"STEP1" COMPLETED','START "STEP2"','RULE_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','"STEP2" COMPLETED','END','RULE_3');
exec dbms_scheduler.enable ('MY_CHAIN');
BEGIN
dbms_scheduler.create_job (
job_name=> 'MY_JOB',
job_type=> 'CHAIN',
job_action=> 'MY_CHAIN',
start_date=> sysdate,
enabled=> true);
END;
/
exec dbms_scheduler.drop_chain('MY_CHAIN',force=>true);
exec dbms_scheduler.create_chain (chain_name=>'MY_CHAIN')
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP1','PROG_1');
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP2','PROG_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','TRUE','START "STEP1"','RULE_1');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN',':step1.state=''SUCCEEDED'' AND to_char(sysdate,''DY'') = ''FRI''','START "STEP2"','RULE_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','"STEP2" COMPLETED','END','RULE_3');
exec dbms_scheduler.enable ('MY_CHAIN');
BEGIN
dbms_scheduler.create_job (
job_name=> 'MY_JOB',
job_type=> 'CHAIN',
job_action=> 'MY_CHAIN',
start_date=> sysdate,
enabled=> true);
END;
/
exec dbms_scheduler.drop_chain('MY_CHAIN',force=>true);
exec dbms_scheduler.create_chain (chain_name=>'MY_CHAIN')
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP1','PROG_1');
exec dbms_scheduler.define_chain_step('MY_CHAIN','STEP2','PROG_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','TRUE','START "STEP1"','RULE_1');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN',':step1.state=''SUCCEEDED'' AND to_char(sysdate,''DY'') = ''MON''','START "STEP2"','RULE_2');
exec dbms_scheduler.define_chain_rule ('MY_CHAIN','"STEP2" COMPLETED','END','RULE_3');
exec dbms_scheduler.enable ('MY_CHAIN');
BEGIN
dbms_scheduler.create_job (
job_name=> 'MY_JOB',
job_type=> 'CHAIN',
job_action=> 'MY_CHAIN',
start_date=> sysdate,
enabled=> true);
END;
/