COBOL Manual for TNS/E Programs (H06.03+)

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-234
START
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).
Suppose a requester asks for a set of records from a member of a context-free
server class: all the records that have a certain alternate key value, or partial value.
If the message buffer cannot hold all such records, the server can return the first
group of records plus the value of the unique key with the reply. This value is that
of the prime record key, the relative key, or the entire alternate key declared as
having no duplicates. Then the requester can ask for another group, supplying the
value of both the partial alternate key and the unique key, and the server can
resume with the last record it had sent or (by using the AFTER phrase) the record
beyond that. The server can remain context-free, because the information
necessary to do the positioning and to establish the key of reference and the
comparison length (for partial keys) accompanies the request.