WRITE for indexed files
For non-VSAMDB files, before the WRITE statement is executed for indexed files, you must set the prime record key (the RECORD KEY data item, as defined in the file-control entry) to the required value. Note that the RECORD KEY values must be unique within the file.
For VSAMDB files defined with an explicit prime key, the JSON document in file record record-name-1 must contain the prime key. The prime key must be unique within the file. The prime record key data item (that is the RECORD KEY data item) is not inspected.
For VSAMDB files defined with an implicit prime key, the JSON document in file record
record-name-1 should not contain the prime key. During execution of the WRITE
statement, VSAM will generate a unique key value and insert it into the document with key name
znsq_id
. Upon successful execution of the WRITE statement the generated key is made available
to the user via the prime record key data item (that is the RECORD KEY data item) as a JSON string
value.
For VSAMDB files defined with an alternate key, the JSON document in file record record-name-1 may contain a JSON key-value pair specifying the alternate key name and value.
If the ALTERNATE RECORD KEY clause is also specified in the file-control entry, each alternate record key must be unique, unless the DUPLICATES phrase is specified. If the DUPLICATES phrase is specified, alternate record key values might not be unique. For non-VSAMDB files, the system stores the records so that later sequential access to the records allows retrieval in the same order in which they were stored.
When ACCESS IS SEQUENTIAL is specified in the file-control entry, records must be released in ascending order of RECORD KEY values.
When ACCESS IS RANDOM or ACCESS IS DYNAMIC is specified in the file-control entry, records can be released in any programmer-specified order.