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
Open Mode
File
Organization
Access
Mode
Statement
INPUT
OUTPUT I-O
EXTEND
INDEXED
SEQUENTIAL
DELETE
READ
REWRITE
START
WRITE
UNLOCK
No
Yes
No
Yes
No
Yes
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
Yes
RANDOM
DELETE
READ
REWRITE
WRITE
UNLOCK
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
DYNAMIC
DELETE
READ
READ NEXT
REWRITE
START
WRITE
UNLOCK
No
Yes
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
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
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......