If the file position indicator was established by a previous READ statement, and the file is a sequential or relative file, or an indexed file whose current key of reference does not allow duplicates, and.PREVIOUS was specified, the first existing record in the file whose record number or key value is less than or equal to the file position indicator is selected.
PREVIOUS was not specified, the first existing record in the file whose record number or key value is greater than or equal to the file position indicator is selected.If the file position indicator was established by a previous OPEN or START statement, and.If the file position indicator indicates that an optional input file is not present, execution proceeds as described below for the case when no next record exists.If the file position indicator indicates that no valid next record has been established, execution of the READ statement is unsuccessful.Comparisons for records in relative files relate to the relative key number.Comparisons for records in indexed files relate to the value of the current key of reference, and the comparisons of key values are made according to the collating sequence of the file. The setting of the file position indicator at the start of the execution of a Format 1 READ statement is used in determining the record to be made available according to the following rules.Comparisons for records in sequential files relate to the record number. data-name-1 or split-key-name-1 may be qualified. When the KEY phrase is present, data-name-1 or split-key-name-1 must be the name of one of the record keys associated with file-name-1. The KEY phrase may be specified only when the organization of file-name-1 is indexed. The INVALID KEY phrase or the AT END phrase must be specified if no applicable USE procedure is specified for file-name-1. In a Format 1 READ statement, the NEXT phrase causes the next logical record to be retrieved from the file, and the PREVIOUS phrase causes the previous logical record to be retrieved.The PREVIOUS phrase may not be specified for a sequential organization file.įor a file in which sequential access mode is specified, a Format 1 READ statement must be used.If both the NEXT phrase and the PREVIOUS phrase are omitted from a Format 1 READ statement for a file in sequential access mode, the default is NEXT.įor a file in which dynamic access mode is specified and records are to be retrieved sequentially using Format 1 READ statements, either the NEXT phrase or the PREVIOUS phrase must be specified.įormat 2 is used for files in random access mode or for files in dynamic access mode when records are to be retrieved randomly. The file referenced by file-name-1 must be open in the INPUT or I–O mode at the time this statement is executed. For sequential access, the READ statement makes available the next or previous logical record from a file.For random access, the READ statement makes available a specified record from a mass storage file.