COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-246
START
Whenever the start operation is successful, if a NOT INVALID KEY phrase is
specified, control passes to the imperative statement in that phrase. If that
imperative statement does not transfer control elsewhere using a GO TO
statement, control then passes to the end of the START statement.
•
Result of Unsuccessful Start Operation
When the execution of a START statement is unsuccessful for any reason, the file
position indicator is set to indicate that no valid next record has been established,
and the key of reference for the file is undefined.
•
START Statement Without the POSITION Phrase
Execution of the START statement establishes the specified key as the key of
reference for the file:
°
For sequential files, an alternate key
°
For relative files, the relative key item or an alternate key
°
For indexed files, a prime key or alternate key
°
For queue files, a prime key
The start operation searches the file for the first record whose value for the key of
reference satisfies the specified relation with respect to the comparison data item.
When the specified key is the prime record key or an alternate record key, the
comparison data item is handled as if it were an alphanumeric data item
(regardless of its actual description) and the normal nonnumeric comparison rules
(using the ASCII collating sequence) apply. When the size of the comparison data
item in character positions is less than that of the file key, the comparison proceeds
as if the record’s key value were truncated on the right to reduce its size to the
equivalent number of characters.
When the file does not contain a qualifying record, the invalid-key condition exists,
and the execution of the START statement is unsuccessful.
When the search succeeds, the file position indicator for the file is set to point to
the record found.
•
START Statement With the POSITION Phrase
A START statement that includes a POSITION phrase also serves to establish a
key of reference and to establish a value for the file position indicator. If more than
one record has the same alternate key, the POSITION phrase determines which
record is read. If the program is reading according to a partial alternate key that
has duplicate values in the file, but the complete alternate key values are unique,
the POSITION phrase has no effect (even if the alternate key is specified with the
DUPLICATES phrase).