START statement
The START statement provides a means of positioning within an indexed or relative file for subsequent sequential record retrieval.
When the START statement is executed, the associated indexed or relative file must be open in either INPUT or I-O mode.
- file-name-1
- Must name a file with sequential or dynamic access. file-name-1 must be defined in an FD entry in the DATA DIVISION and must not name a sort file.
KEY phrase
When the KEY phrase is specified, the file position indicator is positioned at the logical record in the file whose key field satisfies the comparison.
When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is implied.
- data-name-1
- Can be qualified; it cannot be subscripted.
When the START statement is executed, a comparison is made between the current value in the key data-name and the corresponding key field in the file's index.
If the FILE STATUS clause is specified in the file-control entry, the associated file status key is updated when the START statement is executed (See File status key).
INVALID KEY phrases
If the comparison is not satisfied by any record in the file, an invalid key condition exists; the position of the file position indicator is undefined, and (if specified) the INVALID KEY imperative-statement is executed. (See INTO and FROM phrases under "Common processing facilities".)
Both the INVALID KEY phrase and an applicable EXCEPTION/ERROR procedure can be omitted.
END-START phrase
This explicit scope terminator serves to delimit the scope of the START statement. END-START permits a conditional START statement to be nested in another conditional statement. END-START can also be used with an imperative START statement.
For more information, see Delimited scope statements.