Replacing records in a VSAM file
To replace a record in a VSAM file, use REWRITE
on
a file that you opened as I-O
. If the file was not
opened as I-O
, the record is not rewritten and the
status key is set to 49. Check the file status key after each REWRITE
statement.
About this task
For sequential files, the length of the replacement record must be the same as the length of the original record. For indexed files or variable-length relative files, you can change the length of the record you replace.
To replace a record randomly
or dynamically, you do not have to first READ
the
record. Instead, locate the record you want to replace as follows:
- For indexed files, move the record key to the
RECORD KEY
data item, and then issue theREWRITE
. - For relative files, move the relative record number to the
RELATIVE KEY
data item, and then issue theREWRITE
.