4 Replies Latest reply: Mar 7, 2013 11:12 AM by 978204 RSS

    Rule Set Equivalency

    978204
      Is this rule set:

      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP1'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP2'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP1 COMPLETED AND STEP2 COMPLETED', action=>'START STEP3'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP3 COMPLETED', action=>'END '); end;

      equivalent to this rule set:

      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP1'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP2'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP1 COMPLETED', action=>'START STEP3'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP2 COMPLETED', action=>'START STEP3'); end;
      begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP3 COMPLETED', action=>'END '); end;
        • 1. Re: Rule Set Equivalency
          spajdy
          No. In first case step 3 is started when step 1 and step 2 are both completed. This is aka synchronization in multi threats application.

          In case two I'm not sure if this is really possible, because step 3 could be run in parallel. First run is started when step 1 complete a second run start when step 2 complete.
          Job end when step 3 complete, but what happened when on of parallel step 3 complete ? Do job end or wait to second run to complete ?
          • 2. Re: Rule Set Equivalency
            978204
            I asked the question because I have set up both chains and each records the name of the procedure being called. The procedure called in STEP 3 is called one time in both cases.

            I think these are equivalent - if you wanted to run the same program twice in the chain you need to set up two distinct steps [each pointing to the same program].

            Does anyone know the answer?
            • 3. Re: Rule Set Equivalency
              978204
              These rule sets ARE* equivalent. The key thing to remember is each STEP in the chain will be executed once-and-only once.
              • 4. Re: Rule Set Equivalency
                978204
                Upon further investigation, I have found that these two are not_ as equvalent as I thought they were. When there are two rules it is the same as an "OR" statement. Because the action is COMPLETED [which includes SUCCEEDED, FAILED and STOPPED], the results were the exact same, even when one of the steps FAILED.

                However, if I change the statements to use the action, SUCCEEDED, I will get different results:

                When STEP2 action= NON (SUCCEEDED), this chain will stop* after STEP2 with a non-zero ERROR_CODE.

                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP1'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP2'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP1 SUCCEEDED AND STEP2 SUCCEEDED', action=>'START STEP3'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP3 COMPLETED', action=>'END '); end;

                When STEP2 action= NON (SUCCEEDED), this chain will continue* to STEP3 ... because it meets the condition='STEP1 SUCCEEDED'

                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP1'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP2'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP1 SUCCEEDED', action=>'START STEP3'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP2 SUCCEEDED', action=>'START STEP3'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP3 COMPLETED', action=>'END '); end;

                So this last rule set is actually equivalent to:

                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP1'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'TRUE', action=>'START STEP2'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP1 SUCCEEDED OR STEP2 SUCCEEDED', action=>'START STEP3'); end;
                begin dbms_scheduler.define_chain_rule ( chain_name=>'CHN_TEST', condition=>'STEP3 COMPLETED', action=>'END '); end;

                It is an 'OR' action.