COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-198
READ for Random or Dynamic Access
Usage Considerations:
•
Action of the READ Statement (Read According to Key Value)
The execution of this form of the READ statement proceeds:
°
For a file with indexed organization, or a file being accessed according to an
alternate key, the run-time routines set the file position indicator to the first
record in the file with a key data item value that matches the value in the key of
reference. This record is then made available in the file’s record area.
°
For a file with relative organization being accessed according to the relative
record number, the run-time routines set the file position indicator to the record
whose relative record number is contained in the data item named in the
RELATIVE KEY clause for the file. This record is then made available in the
file’s record area.
°
In either case, if no such record exists in the file, the invalid-key condition
exists, and the read operation is unsuccessful.
A successful execution of the READ statement for a relative file, when the key of
reference is an alternate record key, also assigns the relative record number of the
retrieved record to the file’s relative key data item.
When the execution of the READ statement is successful and the access mode is
dynamic, the key of reference established for the read operation is used for
subsequent sequential-type READ statements executed for the same file until the
execution of some other statement explicitly establishes a different key of
reference.
•
File-Status Data Item
If the file has an associated file-status data item, execution of the READ statement
always assigns an appropriate I-O status code.
One possible I-O status code that results from unsuccessful random or dynamic
read operations is:
I-O Status Code Unsuccessful Random or Dynamic Read Operation
“23” The invalid-key condition exists, and the read operation is
unsuccessful