Purge

PURPOSE:  The PURGE command deletes records from the master Data Set (DS) by matching values in the match fields of the master against values in the match fields of the transaction DS.  The records considered for deletion can be limited, and have several options for saving a copy of records on other DS’s.

Syntax

FORM 1:

PURGE WITH clause

[MATCH BY clause; MATCH ON clause]

[IF/:M/; UNLESS/:M/ clause]

[IF:T; UNLESS:T clause]

[IF:A; UNLESS:A clause]

[VIA clause]

[SHOWING clause] [SAVE clause]

[selective_target_clause]

[ADVANCE clause]

[SET clause]

[STOP; END clause]

[/USE/ DOMAIN clause]

WITH clause

described in detail in Chapter 7.

MATCH BY clause

described in detail in Chapter 7.

MATCH ON clause

described in detail in Chapter 7.

IF/:M/; UNLESS/:M/ clause

defines a subset of the master data set.  Described in detail in Chapter 7.

IF:T; UNLESS:T clause

defines a subset of the transaction data set.  Described in detail in Chapter 7.

IF:A; UNLESS:A clause

defines criteria both the master data set records and transaction data set records must satisfy.  It can be used to exclude specific matching records from the output DS. Described in detail in Chapter 7.

VIA clause

when a Process Module (PM) is used with PURGE, the deleted master records are available in the MATCHED section.  Transaction records can also be purged or updated.  Described in detail in Chapter 7.

SHOWING clause 

[SAVE clause]

is executed only for purged records after the SET clause has been applied.  Described in detail in Chapter 7.

selective_target_clause

directs specific subsets of records to output DS’s.  The MATCHED:M records are called PURGED:M and the UNMATCHED:M records are called UNPURGED:M; thus, the forms are:

            [APPEND] PURGED/:M/ TO ds_name

            [APPEND] UNPURGED/:M/ TO ds_name

All other subsets are named as shown in the general discussion of the selective_target_clause in Chapter 7.  The master DS cannot be named as the output DS.

ADVANCE clause

can be used to control the order in which records in master and transaction DS’s are advanced for matching.  Described in detail in Chapter 7.

SET clause

is executed only on the purged records.  This clause is valid only if a SHOWING clause [SAVE clause] or a selective target clause has been  included for PURGED/:M/ records.  Described in detail in Chapter 7.

STOP; END clause

described in detail in Chapter 7.

/USE/ DOMAIN clause

specifies the domain of a Data Index (DI) to be used for the master DS.  Described in detail in Chapter 7.

EXAMPLE

In the example below, BOOKS is the master DS and OLDBOOK is the transaction DS.  The match field is named TITLE_CODE in both DS’s.  The command deletes a BOOKS record when its TITLE_CODE value is the same as a TITLE_CODE value in OLDBOOK.

*USE DS BOOKS
*PURGE WITH OLDBOOK MATCH ON TITLE_CODE

If the DS BOOKS_DBM2 in the above example was indexed, efficiency would be improved by using a MATCH BY clause, since MATCH BY reads only those master records that match a transaction record.  Also, neither master nor transaction DS would have to be sorted.

*USE DS BOOKS DI BOOKS
*PURGE WITH OLDBOOK USE DOMAIN TITLE_CODE & MATCH BY TITLE_CODE

The following command considers only master records with an YTD_SALES value of zero and transaction records whose PUB_DATE is earlier than or equal to the current date.  Only records that pass the conditional clauses are considered for matching.  Of this subset, master records that have a match in the transaction DS are deleted.

*PURGE IF:M YTD_SALES = 0 WITH OLDBOOK IF:T PUB_DATE &
LE @DATE MATCH ON TITLE_CODE

After PURGE matches a transaction record and a master record, it considers any IF:A; UNLESS:A clause to determine which records are purged.  For example, the command below deletes master records that have the same TITLE_CODE value as a transaction record, only if the PRICE field from the master record is less than or equal to the PRICE field in the transaction record.

*PURGE WITH OLDBOOK MATCH ON TITLE_CODE IF:A PRICE:M&<=PRICE:T

NOTES:  Purged records are "deleted in place."

FORM 2:

PURGE SF "string literal"

string literal

Is any specification of a set of file acceptable by the OpenVMS DCL PURGE command.

EXAMPLE

PURGE SF "*.di, *.ds"

This will purge all old versions of DI's and DS's in the current directory.

SEE ALSO:  CLEAR, DELETE Commands