PURPOSE: The ALTER command changes field values in specified records in the current DS. Altered records are written on the current DS, and the unaltered versions of the same records can be sent to other DS’s.
ALTER [/USE/DOMAIN name]
{VIA clause; SET clause}
[WHEN clause]
[IF;UNLESS clause]
[APPEND] TO ds_name [IN DBL clause];
[{IF;UNLESS}] clause [APPEND] TO ds_name [IN DBL clause]; [MULTIPLE]
[SHOWING clause]
[{STOP;END} clause]
[[APPEND] UNQ/UALIFIED/ TO ds_name [IN DBL clause]]
USE/DOMAIN name |
Specifies the domain of a DI. |
VIA clause |
Described in detail in Chapter 7. |
SET clause |
Described in detail in Chapter 7. Either a VIA clause or a SET clause must be included in this command, and both can be included. The SET clause and Process Module (PM) affect the SHOWING clause and those records that pass any conditional clauses; records directed to other DS’s are unaffected. This allows a copy of the records to be saved before they are changed for audit or backup purposes. |
WHEN clause |
Limits indexed retrieval to records having the specified key field values. Described in detail in Chapter 7. |
{IF; UNLESS} clause |
Is a conditional clause. If a single conditional clause is used without TO ds_name, all records that pass the conditional are acted on by the SET clause, the PM, and the SHOWING clause. Described in detail in Chapter 7. |
APPEND TO ds_name [IN DBL clause] |
Creates an output DS. A single TO ds_name clause can be used without a conditional clause. All records are passed to the output DS before changes are applied. If APPEND TO is used the selected data will be appended to the destination DS. If TO is used without APPEND, the selected data will replace the existing contents of the destination DS. The destination DS may reside in the current DBL or in a specified DBL and have the same SD as the current DS. |
{IF; UNLESS} clause [APPEND] TO ds_name |
allows multiple subsets of records to be outputs. Selects records for alteration in the current DS and also selects records for output DS’s. Records appear in output DS’s in their unaltered state. Up to ten clauses can be used to direct data to output DS’s. All output DS’s must already exist and must have a SD identical to that of the current DS. The master DS cannot be named as the output DS. The output DS’s must reside in the current DBL. The IN DBL clause is not allowed for the output DS’s. Described in detail in Chapter 7. If any IF; UNLESS clause is used with TO ds_name, then all additional conditional clauses must also specify output DS’s. Each conditional clause selects records for the respective output DS, and records that pass any of the conditional clauses are altered in the current DS. Records are passed to all output DS’s before alterations are applied. Up to 10 output DS's can be specified. |
Is used, when more than one conditional clause is used, to assure that any record meeting more than one condition is accepted by all the conditional clauses for which it qualifies. If MULTIPLE is not used, a condition clause is satisfied and no other conditional clause in the command will be examined. |
|
This clause shows all altered records. It shows the fields in the altered state. Described in detail in Chapter 7. |
|
{STOP;END} clause |
Described in detail in Chapter 7. |
In the following example, the PRICE and ROYALTY for books in the "TR" category are raised by 2%. The changed values replaced the values in the current DS.
*ALTER IF TITLE_CODE BEGINS WITH "TR" SET PRICE*1.02 TO PRICE, & ROYALTY*1.02 TO ROYALTY
In the next example, PRICE in the selected records is changed on the current DS and in addition, the selected records are written, unaltered, to DS AUDIT.
*ALTER IF TITLE_CODE BEGINS WITH "TR" SET PRICE*1.02 TO PRICE TO AUDIT
The next command uses a Data Index to update a personnel DS. The WHEN clause is much more efficient than an IF; UNLESS clause for changing a few records in a large DS, since ACCENT R reads only those records that satisfy the WHEN clause.
*ALTER USE DOMAIN TITLE_CODE SET "EX" TO NOTES WHEN ROYALTY = 20 THRU 25