Function
The START statement defines the logical starting point within a file for subsequent sequential read operations.
Format
| { IS EQUAL TO | IS = | IS GREATER THAN | IS > | IS NOT LESS THAN | IS NOT < | IS GREATER THAN OR EQUAL TO | IS >= | IS LESS THAN | IS < | IS LESS THAN OR EQUAL TO | IS <= | IS NOT GREATER THAN | IS NOT > } file-name] |
[INVALID KEY imperative-statement-1]
[NOT INVALID KEY imperative-statement-2]
[END-START]
The format extension WITH NO LOCK is effective during shared updating of files; it is described in the "COBOL2000 User Guide" [1].
Syntax rules
Relational operators are mandatory separators. To avoid possible misinterpretations, they have not been underlined in the above format.
file-name must refer to a file in sequential or dynamic access mode.
data-name may be qualified.
For files with relative file organization, data-name must be the name of the RELATIVE KEY data item declared for this file.
For indexed files, data-name must be the name of a RECORD KEY or ALTERNATE RECORD KEY data item declared for that file or an alphanumeric or national data item that is subordinate to the RECORD KEY or ALTERNATE RECORD KEY item. In this case, the first character of both items must be identical.
The INVALID KEY phrase must be present if no applicable USE procedure has been specified.
General rules
For relative and indexed file organization, the following also applies:
The file specified by file-name must be open in the INPUT or I-O mode at the time the START statement is executed (see section "OPEN statement").
If the KEY phrase is omitted from the START statement, the relational operator EQUAL is assumed.
After execution of a START statement, the contents of the FILE STATUS data item (if specified) of that file are updated (see "FILE STATUS clause").
The relational operators have the following effect:
For the relational operators EQUAL, GREATER, GREATER OR EQUAL, NOT LESS and their equivalents, the file position indicator is set to the first record that satisfies the relation.
For the relational operators LESS, LESS OR EQUAL, NOT GREATER and their equivalents, the file position indicator is set to the last record that satisfies the relation.
If the relation condition is not satisfied for any record in the file, an invalid key condition occurs, the file position indicator indicates “invalid” and the START statement is terminated unsuccessfully.
Transfer of control following execution of the START statement depends on whether INVALID KEY or NOT INVALID KEY has been specified (see "Invalid key condition").
For relative file organization, the following also applies:- Execution of the START statement alters neither the content of the record area of the file, nor the file’s RELATIVE KEY nor the content of any data item referenced in a DEPENDING ON phrase of the RECORD clause associated with the file.
The type of comparison is specified by the relational operator in the KEY phrase. The position of each record in the file specified by file-name is compared with the contents of the data item referenced by data-name (RELATIVE KEY).
For indexed file organization, the following also applies:- Execution of the START statement alters neither the content of the record area of the file nor the content of any data item referenced in a DEPENDING ON phrase of the RECORD clause associated with the file.
If an alternate key is specified in the KEY phrase of the START statement, that key becomes the key of reference for subsequent READ statements (format 2).
The type of comparison is specified by the relational operator in the KEY phrase. The logical key of each record in the file specified by data-name is compared with the contents of the data item referenced by data-name (RECORD KEY or ALTERNATE RECORD KEY). If the length of data-name differs from that of the RECORD KEY or ALTERNATE KEY item, the comparison is performed as though the larger data item had been truncated from the right to the length of the smaller item. All key comparisons take place on the basis of the native collating sequence, i.e. as though no PROGRAM COLLATING SEQUENCE IS NATIVE or PROGRAM COLLATING SEQUENCE have been specified.