Compaq COBOL AAQ2G1FTK User Manual

Page 276

Advertising
background image

Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking

Soft Record Locks

Soft record locks can occur only with Compaq standard record locking. A soft
record lock condition, which causes the file status variable to be set to 90,
indicates that the record operation was successful, the record was transferred
to the buffer, and a prior access stream holds a lock on that record. A soft record
lock can be detected by a USE procedure. This condition occurs in either of the
following two situations:

When a record is accessed in a file that has been opened in INPUT mode,
a soft record lock condition may occur if the record has been locked by a
prior stream. This depends on the type of lock held by the first stream and
requested by the subsequent stream.

In the second situation, a stream attempts to access a record that has
been locked by another stream. The second stream employs a READ
REGARDLESS or START REGARDLESS statement (see Bypassing a Record
Lock), which overrides the hard record lock and allows access to the record.
The second stream sucessfully reads the record and receives a soft record
lock. (The second stream cannot update the record.)

For example, a soft record lock results from a situation such as the following,
which uses automatic record-locking mode:

1.

Program A opens the file I-O ALLOWING READERS.

2.

Program A reads a record.

3.

Program B opens the file INPUT ALLOWING ALL.

4.

Program B reads the same record.

5.

Program B receives a soft record lock condition. The record is accessible to
Program B.

6.

Program B’s File Status variable is set to 90.

7.

On OpenVMS, Program B’s USE procedure (if any) is invoked.

8.

Programs A and B continue.

The record was available to Program B.

Note

A file (and thus the records in it) cannot be shared if automatic or manual
record locking is not specified by the user.

A manual record-locking environment is required in order for the REGARDLESS
and ALLOWING options to be used on a READ statement. The READ
REGARDLESS and START REGARDLESS statements should be used only
when the access program clearly needs the existing record regardless of the
possible imminent change in its data. For a full description of the OPEN, READ,
and START statements and their options, see the Compaq COBOL Reference
Manual
.

8–24 Sharing Files and Locking Records

Advertising