Processing Files and Records
6.3 Creating and Processing Files
Table 6–6 lists the valid I/O statements and illustrates the following
relationships:
•
File organization determines valid access modes.
•
File organization and access mode determine valid open modes.
•
All three (organization, access, and open mode) enable or disable I/O
statements.
Table 6–6 Valid I/O Statements for Indexed Files
File
Access
Organization
Mode
INDEXED
SEQUENTIAL
RANDOM
DYNAMIC
Writing an Indexed File
You specify sequential access mode in the Environment Division SELECT clause
when you want to write records in ascending or descending order by primary key,
depending on the sort order. Specify random or dynamic access mode to enable
your program to write records in any order.
Using Segmented Keys in Indexed Files
Segmented keys are a form of primary or alternate keys. A segmented key can be
made up of multiple pieces, or segments. These segments are data items that you
define in the record description entry for a file. They are concatenated, in order of
specification in the ALTERNATE RECORD KEY or RECORD KEY clause, to form
the segmented key, which will be treated like any "simple" primary or alternate
key.
With segmented keys, you have more flexibility in defining record description
entries for indexed files. A segmented key is made up of between one and
eight data items, which can be defined anywhere and in any order within the
record description, and which can even overlap. For example, you might use the
following record definition in your program:
6–34 Processing Files and Records
Statement
INPUT
DELETE
No
READ
Yes
REWRITE
No
START
Yes
WRITE
No
UNLOCK
Yes
DELETE
No
READ
Yes
REWRITE
No
WRITE
No
UNLOCK
Yes
DELETE
No
READ
Yes
READ NEXT
Yes
REWRITE
No
START
Yes
WRITE
No
UNLOCK
Yes
Open Mode
OUTPUT I-O
EXTEND
No
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
No
Need help?
Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?