Sharing Files and Locking Records
8.3 Ensuring Successful File Sharing
If the mode is INPUT (reader), access to the file is granted instead
of denied when a previous updater stream has specified full
(ALL/UPDATERS/WRITERS) or partial (READERS) sharing of
the file.
If the mode is I-O, access is denied as expected.
♦
•
OPEN ALLOWING WRITERS or UPDATERS or ALL—Allows access by other
streams. Other access streams can open the file in INPUT, EXTEND, and I-O
modes.
Compaq COBOL also permits a list of OPEN ALLOWING options, separated by
commas. The list results in the following equivalent ALLOWING specifications:
•
ALLOWING WRITERS, UPDATERS becomes ALLOWING ALL
•
ALLOWING READERS, UPDATERS becomes ALLOWING UPDATERS
The first access stream uses the ALLOWING clause to specify what other access
streams can do. When the second and subsequent access streams attempt to open
the file, the following checks occur:
1.
The allowed options of this access stream are checked against the intended
access of the previous streams.
2.
The intended access of this access stream is checked against the allowed
access of the previous streams.
For example, if the first access stream specifies the ALLOWING READERS
clause, then a subsequent access stream that opens the file ALLOWING NO
OTHERS would fail. Also, if the first access stream opens the file ALLOWING
READERS, the following access stream that opens the file ALLOWING ALL and
WITH I-O mode would fail, because the clause option and the I-O mode declare
write intent to the file.
If you do not specify an ALLOWING clause on the OPEN statement, the default
for files opened for INPUT is ALLOWING READERS, and the default for files
opened for I-O, OUTPUT, or EXTEND mode is ALLOWING NO OTHERS.
Describing Types of Access Streams
You can establish several types of access streams. For example, two programs
opening the same file represent two access streams to that file. Both programs
begin with the file open, perform record operations, and then close the file.
Combining Related File-Sharing Criteria
This section summarizes the relationships among three of the file-sharing criteria
(the first file-sharing requirement, disk residency, is not included).
The following chart shows the file protection and open mode requirements. For
example, the file protection privilege READ ( R ) permits OPEN INPUT.
File Protection
Open Mode
R
INPUT
W
OUTPUT, EXTEND
RW
I-O, INPUT, OUTPUT, EXTEND
Remember that you specify intended operations through the first access stream.
For the second and subsequent shared access to a file, you use the access
intentions (open modes) and the ALLOWING clause to determine if and how
Sharing Files and Locking Records 8–9
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......