4.3 Managing Purge Policies

Purge policies allow the scheduling service to remove completed jobs according to specified criteria. For example, a purge policy might specify the retention of all Java type job requests using a particular job definition submitted executed by a given application for three days. Another purge policy might retain a particular type of job request, say, all SQL job requests in a successful state, for only one day. You can also specify the frequency at which the purge policy is to run.

This section contains the following topics:

4.3.1 Setting Up a New Purge Policy

A purge policy determines which job requests are to be purged and which retained. Defining a purge policy involves:

  • Selecting the jobs to be purged: Selection criteria include the related application or product, a particular job definition or job type, the job submitter or a maximum number of requests.

  • Specifying retention criteria: Decide how long job requests are to be retained depending on their status.

  • Specifying purge frequency: Decide how often you want the purge policy to run.

Note:

After a purge policy has run, it is necessary to physically delete purged job requests from the database. For more information, see Physically Purging Job Requests from the Database.

To set up a new purge policy:

  1. From the navigation pane, expand the Scheduling Services folder and select the Oracle Enterprise Scheduler application.
  2. From the Scheduling Services menu, select Purge Policies.
  3. To configure a new policy, click Setup New.

    In the Setup Purge Policy page, configure the purge policy.

  4. In the Description text field, enter a description for the purge policy.
  5. In the Request Criteria for Purge section, configure the characteristics of the job requests to be purged.
    • Application: From the dropdown list, select the application for which you want to create a purge policy.

    • Product: Enter the name of the product.

    • Job Definition: Click the browse button next to the Job Definition text field.

      In the Select Job Definition window, enter the name of the job definition in the Name text field.

      Click Go to search, then select the relevant job definition from those that display. Click OK.

    • Execution Type: From the dropdown list, select the job type required: All, Java Type, SQL Type, or Process Type.

    • Submitted by: Enter the name of the job submitter.

  6. In the Retention Criteria for Purge section, configure the characteristics of the job requests to be retained.
    • Default Retention Period (in days): Enter the default period, in days, during which requests are to be retained.

    • Retention Period - Success (in days): Enter the period, in days, during which successful job requests are retained.

    • Retention Period - Error (in days): Enter the period, in days, during which errored job requests are retained.

    • Retention Period - Warning (in days): Enter the period, in days, during which job requests ending in a warning status are retained.

    • Retention Period - Cancelled (in days): Enter the period, in days, during which canceled job requests are retained.

  7. In the Schedule section, set a schedule for the job request purge policy.
    • To run the purge policy only one time, select Once. Click the Calendar button to select the date and time you want the purge policy to run.

    • To set a schedule for the purge policy, select Use Existing Schedule. Click the browse button to search for a schedule.

      In the Select Schedule window, select a schedule and click OK.

  8. In the Advanced section, in the Maximum requests to be processed text field, enter the maximum number of job requests to be processed.
  9. Click OK to save the purge policy.

4.3.2 Physically Purging Job Requests from the Database

Job request data is kept in the Oracle Enterprise Scheduler run-time store as records in the run-time store tables. These job requests records are kept in the run-time store until they are physically purged by a database administrator using SQL purge scripts. You must logically delete a job request before physically purging it.

Use the method esspurge.purge_requests on the Oracle Enterprise Scheduler schema to delete purged job requests from the database. In an Oracle Fusion Applications environment, the schema is typically called FUSION_ORA_ESS.

The ESSPURGE package contains a stored procedure which you can use to purge completed job requests. The package is normally loaded when the Oracle Enterprise Scheduler schema is created or updated. The stored procedure is shown in Example 4-1.

The basic syntax of esspurge.purge_requests is shown in Example 4-2, where FUSION_ORA_ESS is the name of the Oracle Enterprise Scheduler schema and password is the password.

Additional examples are shown in the following list.

  • To purge job requests completed earlier than the current time, at a maximum of 50000 job requests, execute the following command:

    execute esspurge.purge_requests(systimestamp, 50000);
    
  • To purge job requests completed 30 days earlier, at a maximum of 50000 job requests, execute the following command:

    execute esspurge.purge_requests(systimestamp - 30, 50000);
    
  • To purge job requests that completed before June 01, 2010 at 15:00:00 (UTC), at a maximum of 50000 job requests, execute the following command:

    execute esspurge.purge_requests(TIMESTAMP '2010-06-01 15:00:00 -00:00', 50000);
    

Example 4-1 ESSPURGE Stored Procedure for Purging Completed Job Requests

--- Purges job requests that have completed.
---
--- p_older_than : Purge only job requests that have completed after this time.
--- p_max_count : The maximum number of job requests to purge.
--- p_max_runtime : The maximum time, in minutes, the purge should run.
---    If null (default), this defaults to one day which effectively means
---    there is no time limit.
---
procedure purge_requests
( p_older_than in timestamp,
  p_max_count in number,
  p_max_runtime integer default null );

Example 4-2 Purging Job Requests from the Database

sqlplus FUSION_ORA_ESS/password
set serveroutput on size unlimited
set timing on
execute esspurge.purge_requests(systimestamp, 1000000);

4.3.3 Viewing Purge Policies

You can view all purge policies defined for the scheduling service.

To display purge policies for the scheduling service:

  1. From the navigation pane, expand the Scheduling Services folder and select the Oracle Enterprise Scheduler application.
  2. From the Scheduling Services menu, select Purge Policies.

4.3.4 Updating a Purge Policy

You can edit the request or retention criteria of an existing purge policy, as well as the purge policy schedule as long as the purge policy is not in the "Succeeded" or "Cancelled" state.

To update a purge policy:

  1. From the navigation pane, expand the Scheduling Services folder and select the Oracle Enterprise Scheduler application.
  2. From the Scheduling Services menu, select Purge Policies.
  3. From the Purge Policies table, select the policy you want to update and click Update.
  4. Edit the purge policy accordingly and click OK.

4.3.5 Deleting a Purge Policy

You can delete a given purge policy as long as it is not in the "Wait" or "Hold" state.

To delete a purge policy:

  1. From the navigation pane, expand the Scheduling Services folder and select the Oracle Enterprise Scheduler application.
  2. From the Scheduling Services menu, select Purge Policies.
  3. From the Purge Policies table, select the policy you want to delete and click Delete.