Compaq COBOL AAQ2G1FTK User Manual

Page 264

Advertising
background image

Sharing Files and Locking Records
8.3 Ensuring Successful File Sharing

Legend

6

For indexed files, when the first stream allows READERS, file lock does
not exclude updaters allowing sharing. For files other than indexed, 4
applies.

7

For indexed files, the second stream is granted access but cannot update
the file. For files other than indexed, 4 applies.

In the following example, three streams illustrate some of the file-sharing rules:

STREAM 1

OPEN INPUT ALLOWING ALL

STREAM 2

OPEN INPUT ALLOWING READERS

STREAM 3

OPEN I-O ALLOWING UPDATERS

Stream 1 permits ALLOWING ALL; thus stream 2 can read the file. However,
the third stream violates the intent of the second stream, because OPEN I-O
implies a write intention that stream 2 disallows. Consequently, the third access
stream receives a file locked error.

8.3.6 Error Handling for File Sharing

This section describes error conditions, checking file operations for success or
failure, some considerations when you specify the OPEN EXTEND statement,
and related potential errors.

Error Conditions

Whether the syntax is X/Open standard or Compaq standard, any file contention
error results in an unsuccessful statement for which a USE procedure will be
invoked. A ‘‘file-locked’’ condition results in an I-O status code of 91.

It is invalid to specify both X/Open and Compaq standard file sharing for the
same file connector. Any attempts are flagged by the compiler when detectable in
a single compilation unit. Across compilation units, the run-time system detects
and reports such violations. This restriction is true for explicit and implicit
(default) usage.

Checking File Operations

You can check the success or failure of a file open operation by using the File
Status value (or, on OpenVMS Alpha systems, the RMS-STS value in a Compaq
COBOL special register called RMS-STS).

Table 8–3 illustrates the file status values you frequently use in a file-sharing
environment.

Table 8–3 File Status Values Used in a File-Sharing Environment

File Status Value

Meaning

00

Successful operation

30

File protection violation

91

File is locked

File Status 00 indicates the completion of a successful operation.

File Status 30 might result from a violation of the file protection codes described
in Section 8.3.2. To correct this condition, the file owner must reset the protection
on the file or the directory that contains the file.

8–12 Sharing Files and Locking Records

Advertising