Compaq COBOL AAQ2G1FTK User Manual
Page 203
Processing Files and Records
6.2 Identifying Files and Records from Within Your Compaq COBOL Program
Record Access Mode
The methods for retrieving and storing records in a file are called record access
modes. Compaq COBOL supports the following three types of record access
modes:
•
ACCESS MODE IS SEQUENTIAL
With sequential files, sequential access mode retrieves the records in the
same sequence established by the WRITE statements that created the file.
With relative files, sequential access mode retrieves the records in the
order of ascending record key values (or relative record numbers).
With indexed files, sequential access mode retrieves records in the order
of record key values.
•
ACCESS MODE IS RANDOM—The value of the record key your program
specifies indicates the record to be accessed in Indexed and Relative files.
•
ACCESS MODE IS DYNAMIC—With relative and indexed files, dynamic
access mode allows you to switch back and forth between sequential access
mode and random access mode while reading a file by using the the NEXT
phrase on the READ statement. For more information about dynamic access
mode, see READ and REWRITE statements in the Compaq COBOL Reference
Manual.
When you omit the ACCESS MODE IS clause in the SELECT statement, the
access mode is sequential.
Example 6–17 shows sample SELECT statements for sequential files with
sequential access modes.
Example 6–17 SELECT Statements for Sequential Files with Sequential Access Mode
(1)
(2)
FILE-CONTROL.
FILE-CONTROL.
SELECT LIST-FILE
SELECT PAYROLL
ASSIGN TO "MAIL.LIS"
ASSIGN TO "PAYROL.DAT".
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL.
Sample SELECT statements for relative files with sequential and dynamic access
modes are shown in Example 6–18.
Example 6–18 SELECT Statements for Relative Files with Sequential and Dynamic Access
Modes
(1)
(2)
FILE-CONTROL.
FILE-CONTROL.
SELECT MODEL
SELECT PARTS
ASSIGN TO "ACTOR.DAT"
ASSIGN TO "PART.DAT"
ORGANIZATION IS RELATIVE
ORGANIZATION IS RELATIVE
ACCESS MODE IS SEQUENTIAL.
ACCESS MODE IS DYNAMIC
RELATIVE KEY IS PART-NO.
Processing Files and Records 6–23