Function
The ACCESS MODE clause determines the manner in which the records of a file are to be accessed.
Format 1 for sequential file organization
ACCESS MODE IS SEQUENTIAL
Format 2 for relative file organization
ACCESS MODE IS { SEQUENTIAL [RELATIVE KEY IS data-name-1]
| {RANDOM | DYNAMIC} RELATIVE KEY IS data-name-1
}
Syntax rules
The RELATIVE KEY phrase specifies the key field whose content is used for retrieving or placing a logical record in a file.
data-name-1 must not be subscripted or indexed.
The data item referenced by data-name-1 must be defined as an unsigned integer. The symbol "P" may not be specified in its PICTURE character string.
data-name-1 must not be specified within the record description entry of the associated file.
Format 3 for indexed file organization
ACCESS MODE IS {SEQUENTIAL | RANDOM | DYNAMIC}
General rules
For sequential, relative and indexed file organization:
If the ACCESS MODE clause is not specified, ACCESS MODE IS SEQUENTIAL is assumed.
SEQUENTIAL means that records are read or written sequentially, i.e. the next logical record of the file is made available when a READ statement is executed, or the next logical record is placed on that file when a WRITE statement is executed.
If the ACCESS MODE clause refers to an external file, an equivalent ACCESS MODE clause must be specified in all other programs that describe this external file.
Furthermore, in the case of files with relative organization, data-name-1 must be an external data item identical in all programs.
The following also applies to relative and indexed file organization:RANDOM means that records are randomly read or written on the basis of a key, i.e. access is achieved via the RELATIVE KEY.
DYNAMIC means that random and sequential access may be combined.
The following applies only to relative file organization:The data item referenced by data-name-1 is used for communicating a relative record number between the user and the input/output system.
All records which exist on a file are uniquely identified by their relative record numbers. The relative record number of a given record specifies the logical position of that record within the file record sequence. The first logical record is relative record number one (1), and the following logical records have the relative record numbers 2, 3, 4... .
The RELATIVE KEY must not be zero.