Relationship between data organizations and access modes
This section discusses which access modes are valid for each type of data organization.
- Sequential files
- Files with sequential organization can be accessed only sequentially. The sequence in which records are accessed is the order in which the records were originally written.
- Line-sequential files
- Same as for sequential files (described above).
- Indexed files
- All three access modes are allowed.
In the sequential access mode, the sequence in which records are accessed is the ascending order of the record key value. The order of retrieval within a set of records that have duplicate alternate record key values is the order in which records were written into the set.
In the random access mode, you control the sequence in which records are accessed. A specific record is accessed by placing the value of its key or keys in the RECORD KEY data item (and the ALTERNATE RECORD KEY data item). If a set of records has duplicate alternate record key values, only the first record written is available.
In the dynamic access mode, you can change as needed from sequential access to random access by using appropriate forms of input-output statements.
- Relative files
- All three
access modes are allowed.
In the sequential access mode, the sequence in which records are accessed is the ascending order of the relative record numbers of all records that exist within the file.
In the random access mode, you control the sequence in which records are accessed. A specific record is accessed by placing its relative record number in the RELATIVE KEY data item; the RELATIVE KEY must not be defined within the record description entry for the file.
In the dynamic access mode, you can change as needed from sequential access to random access by using appropriate forms of input-output statements.