2 Replies Latest reply on Sep 14, 2021 6:40 AM by JanLeendert Wijkhuijs

    Out of 10 sessions in a WF, how to run one session only once a day

    Lavanya Sekar New Member

      Hello,

       

      I have a WF, in which I have 10 sessions, which are scheduled to run cyclic throughout the day.

      I want to create a new session, but I want that to execute only once a day, whereas the other sessions can keep running cyclic.

      Please tell me how to achieve this.

      Thank you.

        • 1. Re: Out of 10 sessions in a WF, how to run one session only once a day
          Alexandru Stan New Member

          Hello,

          one sollution will be like this:

           

          Create one Table T_LAST_DAY_RUN which will have just one column. run_day, type Date (or date time or timestamp, depending on your DB). Don't use a flat file as target, can be erased at session start.

           

          Create one Source using the same table.

           

          Create one mapping, m_check_last_day with the two elements.

          In the Source Qualifier use something like select nvl(max(run_day), sysdate -1) from t_last_day_run. Max is needed for the first run, when the table is empty, can be removed if you are sure that the table will allways have at least row.

          Compare the actual date (trunc(run_day))  with the actual date (without the time part!) and insert the date in target if necessary.

           

          In workflow, before the session X, create a new session s_m_check_last_day with the new mapping.

          Create two task links, one from s_m_check_last_day to session X, with the condition TgtSuccessRows

          and one from s_m_check_last_day to session X + 1, with the condition TgtSuccessRows = 0.

           

          Session X+1 has to have the property "Treat the input links as" set to OR

           

          As an extra, in the table T_LAST_DAY_RUN you will have now the whole run history of m_check_last_day.

          Regards,

          Alexandru Stan

          • 2. Re: Out of 10 sessions in a WF, how to run one session only once a day
            JanLeendert Wijkhuijs Guru

            Hi,

             

            There is also another possibility which you can apply.
            You can also use a workflow variable (e.g. $$WF_CHECK_RUN_DATA) and a mapping/session variable.

            In the mapping you can create a variable e.g. $$CHECK_RUN_DATA with data type datetime.

            In the mapping you can use a variable port (also data type datetime) in an expression to set the variable.
            I would use: SETVARIABLE($$CHECK_RUN_DATA,ADD_TO_DATE(TRUNC(SESSSTARTTIME,'DD'),'DD',1)) In the session you can pass the mapping variable to the workflow variable (note this one must be persistent)

             

            In the connection to the session you can have the logic SYSDATE >= $$WF_CHECK_RUN_DATA

            Once the session did complete succesful the variable is passed to the workflow.

            Hope this helps.Regards

            Jan Leendert