Aborting Workflows – Adding A Date Restriction

Back in April, there was a post on OTN relating to whether you could specify the date when aborting a Workflow process using the standard WF_ENGINE.AbortProcess API. The reason seemed to be that the user only wanted to purge data according to a specific date (e.g. up to the end of 2010).

As I said in my response, it doesn’t make sense to try to convince the system that you did something on a different date. If you set it to BEGIN_DATE+10, what happens to the child activities which occurred on BEGIN_DATE + 11? You would have an end date that was before the begin date, which doesn’t do much for any auditing and reporting that you want to do.

If the requirement is actually to abort and purge processes which started before a certain date, then the code below should help:

BEGIN
  FOR i IN ( SELECT item_type
             ,      item_key
             FROM   wf_items
             WHERE  1 = 1 ) LOOP
    WF_ENGINE.AbortProcess ( i.item_type, i.item_key );
  END LOOP;
 
  FOR j IN ( SELECT item_type
             ,      item_key
             FROM   wf_items
             WHERE  TRUNC(begin_date) <= TRUNC(TO_DATE('31-DEC-2010'
                                         ,'DD-MON-YYYY')) ) LOOP
    WF_PURGE.items ( j.item_type, j.item_key );
  END LOOP
END;

Modify the implicit cursor in the i loop to find the records that you want to abort, modify the cursor in j loop to include any other criteria.

The reason that you have to do them in loops is to ensure that the processes have all been aborted before trying to purge them - the process (and any child processes it spawns) must be complete before it can be purged. Likewise, when purging child flows, the parent must have completed before it can be purged (something I suggested as a feature many years back :))

By continuing to use the site, you agree to the use of cookies. more information

In common with almost all professionally run websites, this website logs the IP address of each visitor in order to keep it running reliably. This is also essential for protecting the website and its visitors from malicious attacks, including infection with malware.

This website provides information as a service to visitors such as yourself, and to do this reliably and efficiently, it sometimes places small amounts of information on your computer or device (e.g. mobile phone). This includes small files known as cookies. The cookies stored by this website cannot be used to identify you personally.

We use cookies to understand what pages and information visitors find useful, and to detect problems such as broken links, or pages which are taking a long time to load.

We sometimes use cookies to remember a choice you make on one page, when you have moved to another page if that information can be used to make the website work better. For example:
- avoiding the need to ask for the same information several times during a session (e.g. when filling in forms), or
- remembering that you have logged in, so that you don’t have to re-enter your username and password on every page.

You can prevent the setting of cookies by adjusting the settings on your browser (see your browser Help for how to do this). Be aware that disabling cookies will affect the functionality of this and many other websites that you visit.

Close