COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-195
READ for Random or Dynamic Access
READ for Random or Dynamic Access
READ is for random or dynamic access reads a record from a file according to the
value of a key, rather than according to the present value of the file position indicator.
For relative files, READ without NEXT sets the file position indicator to the item
selected by RELATIVE KEY (if KEY is omitted) or to the specified alternate key.
For indexed and queue files, READ without NEXT sets the file position indicator to the
item selected by either the key of reference (if KEY is omitted) or to the specified prime
or alternate key.
When the selected record exists, the process places its contents in the record area. If it
does not exist, an invalid-key condition occurs, and the process executes either the
INVALID KEY statement or, if there is no INVALID KEY phrase, a USE AFTER
EXCEPTION procedure.
When duplicate alternate key values are allowed, the order of records with equal
values depends on the INSERTIONORDER parameter of the alternate key file: records
with duplicate alternate key values are retrieved in either prime key order (the way
NonStop systems software ordinarily works) or in the order in which they were inserted
in the file (as specified in the 1985 ISO/ANSI COBOL standard).