UPDATE command use

The following examples illustrate the use of the UPDATE command:

Example 1—update a table

Update table TABLEXX with the data on the file identified by the DDNAME UPDFILE, removing those rows whose keys are found on DELFILE.

UPDATE TBL=TABLEXX WITH=UPDFILE REMOVE=DELFILE;

Example 2—eliminate duplicates

A file is available containing a record for each product ordered in a company. The supplier is contained in position 20 for a length of 10. A list of all suppliers on the file is required. The following code eliminates duplicate suppliers if there are multiple occurrences, prints the resulting table contents, and then deletes the temporary table.

DEFINE TBL=SUPPLIER ORG=S KLOC=20 KSZ=10 ISZ=30;
UPDATE TBL=SUPPLIER WITH=PRODUCT;
PRINT TBL=SUPPLIER;
DELETE TBL=SUPPLIER ALLGEN=YES;

Note:
For each record on the WITH file, the corresponding record will be replaced in its entirety, provided that the key is matched in the table. Therefore, the resultant table will not contain any duplicate supplier records.