0 Replies Latest reply on Mar 7, 2013 11:23 PM by 978204

    Be careful with NOT rules

    978204
      I have a 3-step chain with a rule set like this:

      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'TRUE', action=>'START "step1"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step1" COMPLETED', action=>'START "step2"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" SUCCEEDED', action=>'START "step3"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" FAILED', action=>'END 1'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step3" COMPLETED', action=>'END '); end;

      When I run the chain and "step2" fails, the SCHEDULERJOB_RUN_DETAILS view shows the following execution path:

      step1=SUCCEEDED
      step2=FAILED
      CHAIN ERROR#=1

      which is exactly what I expected.

      If I change the rule set to use '"step2" NOT SUCCEEDED' instead of '"step2" FAILED' like this:

      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'TRUE', action=>'START "step1"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step1" COMPLETED', action=>'START "step2"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" SUCCEEDED', action=>'START "step3"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" NOT SUCCEEDED', action=>'END 1'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step3" COMPLETED', action=>'END '); end;

      When I rerun the chain, the SCHEDULERJOB_RUN_DETAILS view shows the following execution path:

      CHAIN ERROR#=1

      The chain immediately stops; "step1" is not run; "step2" is not run; yet the ERROR#=1
      Upon starting the chain, it looked at the 4th rule in the rule set and determined that it was TRUE.

      I instead need to use '"step2" COMPLETED AND "step2" NOT SUCCEEDED' like this:

      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'TRUE', action=>'START "step1"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step1" COMPLETED', action=>'START "step2"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" SUCCEEDED', action=>'START "step3"'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step2" COMPLETED AND "step2" NOT SUCCEEDED', action=>'END 1'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'chn_test5', condition=>'"step3" COMPLETED', action=>'END '); end;

      When I run the chain and "step2" fails, the SCHEDULERJOB_RUN_DETAILS view shows the following execution path:

      step1=SUCCEEDED
      step2=FAILED
      CHAIN ERROR#=1