Compaq COBOL AAQ2G1FTK User Manual

Page 272

Advertising
background image

Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking

When you specify manual record locking you must use all of the following clauses:

An APPLY LOCK-HOLDING clause in the I-O CONTROL paragraph

An OPEN ALLOWING clause at file open time

An ALLOWING clause on each record operation (except DELETE)

2

The possible ALLOWING clauses for the record operations (that is, the READ,
WRITE, REWRITE, and START statements) are as follows:

ALLOWING NO OTHERS

2

—Locks records for exclusive access. Others

cannot perform READ, WRITE, DELETE, or UPDATE statements. This
clause constitutes a lock for write and does not allow readers.

ALLOWING READERS—Locks records against WRITE, REWRITE, and
DELETE access by all streams including the stream that issues the
statement. Others can perform READ statements.

ALLOWING UPDATERS

2

—Does not apply any locks to the records. Others

can perform READ, REWRITE, and DELETE statements. This clause
constitutes a no record lock condition.

2

However, if the file’s OPEN mode is INPUT, using the ALLOWING clause on the
record operation does not lock the record.

On Tru64 UNIX and Windows NT systems, for indexed files only, the WRITE,
REWRITE, and START statements do not acquire a record lock.

On Tru64 UNIX and Windows NT systems for indexed files only, ALLOWING
READERS is treated as ALLOWING NO OTHERS if the file is opened in I-O
mode or as ALLOWING ALL if the file is opened in INPUT mode.

Table 8–5 shows the valid and invalid ALLOWING combinations for manual
record locking. The columns represent the lock held, and the rows represent the
lock requested.

Table 8–5 Manual Record Locking Combinations

Lock Held (for first stream)

I-O Attempt (for

subsequent stream)

Updaters

Readers

No Others

READ

Allowing Updaters

Y

Y

N

Allowing Readers

Y

Y

N

Allowing no others

Y

N

N

REWRITE

Allowing no others

Y

N

N

DELETE

Y

N

N

START

Allowing Updaters

Y

Y

N

(continued on next page)

2

Some exceptions exist on Windows NT and Tru64 UNIX. See Compaq COBOL Reference
Manual
for details.

8–20 Sharing Files and Locking Records

Advertising