COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-189
READ for Sequential or Dynamic Access
If the TIME LIMIT phrase is specified with a nonnegative value and the file is not
opened with time limits enabled, the program terminates with an I-O status code
“90,” and a message (File is not opened for timed I-O) is delivered to the process’s
home terminal.
The effect of declaratives on time-limit termination is:
°
If there is no declarative procedure applicable to the file when the operation is
abandoned, the process terminates, and an ABEND message is reported to
the process’s home terminal.
°
If the applicable declarative procedure is present (but no AT END phrase is
present) and the time interval expires, the declarative procedure is performed.
Then program execution continues with the imperative statement in the NOT
AT END phrase, if one is present, or otherwise with the statement following the
one terminated.
When a file is being read with APPROXIMATE positioning (see START), the
value used for wait-time must take into account that a read operation can
take somewhat longer than expected. This can occur when a nonexistent
record is sought, because the file system searches through the file looking for
the next defined record before reporting the absence of the record sought. See
the Guardian Programmer’s Guide for more information on the action of READ.
•
Concept of Next Record
READ NEXT is used to read the next record of a file whose access mode is
SEQUENTIAL or DYNAMIC. Files whose access mode is SEQUENTIAL can be
read without the NEXT keyword, but each such read gets the “next record” in the
file. The “next record” means “next existing record within the established key of
reference.”
°
If the last operation on the file was a start operation (or open operation, in the
case of relative, indexed, or queue files), and the record selected by the file
position indicator is still accessible through the file position indicator, that
record is read.
°
If the last operation on the file was a read operation (either a READ KEY or a
READ NEXT), or if the record selected by the file position indicator is no longer
accessible through the file position indicator (due to deletion or a change of the
alternate key), the file position indicator is updated to point to the next existing
record in the file, and that record is read.
°
If the value of the file position indicator for the file is undefined when execution
of the READ statement begins, the read operation is unsuccessful, and any
file-status data item declared for the file in the file-control entry is updated to
specify the reason.