

Data Manipulation Language Statements › @MODIFY—replaces element values of the database record
@MODIFY—replaces element values of the database record
The @MODIFY statement replaces element values of the specified database record with new element values present in program variable storage.
Before execution of the @MODIFY statement, the following conditions must be met:
- All areas affected, either implicitly or explicitly, must be readied in one of the update usage modes (see @READY in this chapter).
- The named record must be established as current of run unit. If the record that is current of run unit is not an occurrence of the named record, an error condition results.
- The values of all elements defined for the named record in the subschema view must be in variable storage. If the @MODIFY statement is not preceded by an @OBTAIN statement, you must initialize the appropriate values. It is recommended that you issue an @OBTAIN statement to ensure that all the elements in the modified record are present in variable storage before you alter the values, then issue the @MODIFY statement.
Modifying CALC- and Sort-Control Elements
The following special considerations apply to the modification of CALC- and sort-control elements:
- If modification of a CALC- or sort-control element will violate a duplicates-not-allowed option, the record is not modified and an error condition results.
- If a CALC-control element is modified, successful execution of the @MODIFY statement enables the record to be accessed on the basis of its new CALC-key value. The db-key of the specified record is not changed.
- If a sort-control element is to be modified, the sorted set in which the named record participates must be included in the subschema invoked by the program. A record occurrence that is a member of a set not defined in the subschema can be modified if the undefined set is not sorted.
- If any of the modified elements in the specified record are defined as sort-control elements for any set occurrence in which that record is currently a member, the set occurrence is examined. If necessary, the specified record is automatically disconnected and reconnected in the set occurrence to maintain the set order specified in the schema.
Native VSAM Considerations
The following special considerations apply to the modification of records in native VSAM data sets:
- The length of a record in an entry-sequenced data set (ESDS) cannot be changed even if the record is variable length.
- The prime key for a key-sequenced data set (KSDS) cannot be modified.
Currency
Before execution of the @MODIFY statement:
- The specified record must be established as current of run unit. If the record that is current of run unit is not an occurrence of the specified record, an error condition results.
- The values of all elements defined for the named record in the program's subschema view must be in variable storage. If the @MODIFY statement is not preceded by an @OBTAIN statement, the programmer must initialize the appropriate values. The best practice is to issue an @OBTAIN statement to ensure that all the elements in the modified record are present in variable storage before altering the values as desired and then issue the @MODIFY statement.
Following a successfully executed @MODIFY statement, the modified record becomes current of its run unit, record type, area, and all sets in which in participates as owner or member.
Copyright © 2014 CA.
All rights reserved.
 
|
|