In COBOL the indexed files you can be accessed in 3 ways (Refer previous post). There are few key differences on the options especially in the access modes. Below is the complete list of file access mode options for indexed files.
You can have any one of the below 3 access modes for Indexed files. The files, which you are defined as sequential, then can read only in sequential way.
The records you defined for Random access – You can access in any order how you defined. Example – RECORD KEY, ALTERNATE KEY or RELATIVE KEY
The files defined with Dynamic access modes, then it can be accessed Sequential or Random way.
SEQUENTIAL Access supports the following file manipulation options
RANDOM Access supports the following options
DYNAMIC Access supports the following options
- READ NEXT
START and READ NEXT highly useful for Random and Dynamic access modes.
The START will position the record:
START file-name KEY IS EQUAL TO ALTERNATE-RECORD-KEY
Among the above options “READ NEXT” differentiates out of all. Since for random reading “READ” alone is not enough. If you want sequential reading of INDEXED file, then you need “READ NEXT” option.
So, the next record you can read sequentially with ‘READ NEXT’ statement.