COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-197
READ for Random or Dynamic Access
LOCK
keeps other programs from using the record retrieved until an UNLOCKFILE
statement, UNLOCKRECORD statement, or UNLOCK phrase is executed on the
record.
wait-time
is the time interval, in seconds, in which the operation must complete. wait-time
can be a literal or the name of a data item. In either case, it must have a value
described with at most seven digits preceding any decimal point position. Any
fractional portion is truncated to two decimal places.
If file-name was not opened with a TIME LIMITS phrase, including wait-time
in the READ statement causes a run-time error.
key
is the key of reference. If file-name specifies a relative file, key must be an
alternate key for that file. If file name specifies an indexed file, key can be the
prime key or an alternate key. If file-name specifies a queue file, key must be
the prime key for that file. Unlike the START statement, the KEY clause provides
only APPROXIMATE positioning—not GENERIC positioning.
When the KEY phrase is absent, the relative key (for a relative file) or the prime
record key (for an indexed or queue file) is established as the key of reference.
imperative-stmt-1
is an imperative statement to be performed when an invalid key is encountered at
the beginning of the READ. It is required if no USE statement is applicable for the
file. If both a USE statement and an INVALID KEY phrase are present, only the
INVALID KEY phrase is used.
imperative-stmt-2
is an imperative statement to be performed when no invalid key is encountered at
the beginning of the read operation.
END-READ
ends the scope of the READ statement, causing the READ to be a delimited-scope
statement. If the READ statement does not end with an END-READ phrase, the
presence of the INVALID KEY or the NOT INVALID KEY phrase causes the READ
statement to be a conditional statement, which ends at the next period separator.