Purpose: The UPDATE command changes values in selected fields in the master Data Set (DS). Processing is based on matching the key fields of transaction records and master records.
UPDATE WITH clause
{MATCH BY clause; MATCH ON clause}
{VIA clause; SET clause}
[SHOWING clause] [SAVE clause]
[selective target clause]
[STOP; END clause]
[IF/:M/; UNLESS/:M/ clause]
[IF:T; UNLESS:T clause]
[IF:A; UNLESS:A clause]
[ADVANCE clause]
[/USE/ DOMAIN name]
WITH clause |
described in detail in Chapter 7. |
MATCH BY clause |
described in detail in Chapter 7. |
MATCH ON |
described in detail in Chapter 7. |
VIA clause |
described in detail in Chapter 7. |
SET clause |
described in detail in Chapter 7. |
SHOWING clause [SAVE clause] |
shows the records as affected by a SET clause or a PM. Described in detail in Chapter 7. |
selective_target_clause |
outputs records unaffected by either the PM or the SET clause. Thus a copy of the record as it was before updating can be saved for backup or audit. The master DS cannot be named as the output DS. Described in detail in Chapter 7. |
STOP; END clause |
described in detail in Chapter 7. |
F/:M/; UNLESS/:M/ clause |
described in detail in Chapter 7. |
IF:T; UNLESS:T clause |
described in detail in Chapter 7. |
IF:A; UNLESS:A clause |
described in detail in Chapter 7. |
ADVANCE 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. |
In the first example, for each match, the quantity from the transaction DS is added to the value in QTY in the master DS, and the current date to the master field ORDER_DATE. The audit DS MSALE contains all the matched master records as they were before updating.
*UPDATE WITH SALEDAT MATCH ON ORD_NUM SET QTY:M + &
QTY:T TO QTY:M, @DATE TO ORD_DATE:M MATCHED:M TO MSALE
The next example screens master records with a conditional clause. Only records having a quantity less than 50 are considered for matching. After a master and transaction record are found to match, the IF:A clause is checked. If QTY in the transaction record is greater than QTY in the master record, the master value is replaced.
*UPDATE WITH SALEDAT MATCH ON ORD_NUM:M IF QTY<50 SET QTY:T TO
QTY:M IF:A QTY:T>QTY:M
The next example updates an indexed DS. By employing MATCH BY instead of MATCH ON, the user improves efficiency of access and also avoids sorting either DS.
*USE DS STORES DI STORES
*UPDATE WITH NEWSTORE USE DOMAIN STORE_CODE MATCH BY STORE_CODE &
SET NEWZIP:T TO ZIP:M
NOTES: UPDATE always affects the master record. Either the VIA clause or the SET clause must be used