Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking
8.4.1 X/Open Standard Record Locking
This section describes the X/Open standard method of specifying automatic or
manual record locking.
Specifying Automatic Record Locking (X/Open Standard)
You specify X/Open standard automatic record locking in the Environment
Division by using LOCK MODE IS AUTOMATIC [WITH LOCK ON RECORD] on
the SELECT statement. (The optional WITH LOCK ON RECORD clause has no
effect and is for documentation only.) Subsequently, a record lock is acquired by
the successful execution of a READ statement. (The WITH LOCK clause is not
necessary on the READ; it is implied.)
A record lock is released by one of the following events:
•
The successful execution of a subsequent I-O statement
•
Using the UNLOCK statement
•
Closing the file, implicitly or explicitly
In X/Open standard record locking, only the READ statement can acquire a lock.
You can use the WITH NO LOCK phrase of the READ statement to prevent the
acquiring of an automatic record lock.
For files opened in INPUT mode, READ and READ WITH LOCK statements do
not acquire a record lock.
Specifying Manual Record Locking (X/Open Standard)
You specify X/Open standard manual record locking in the Environment Division
by using LOCK MODE IS MANUAL WITH LOCK ON MULTIPLE RECORDS on
the SELECT statement. Manual record locking is available only for relative and
indexed files.
For manual record locking, a record lock is acquired by specifying the WITH
LOCK phrase on the READ statement. READ is the only operation that can
acquire a lock. The record lock is released by one of the following events:
•
Using the UNLOCK statement (any form of the UNLOCK statement unlocks
all record locks held by the current access stream; there is no singular option)
•
Closing the file, implicitly or explicitly
The WITH LOCK clause is ignored for files opened in INPUT mode. Locks are
detected but not acquired.
Example 8–4 is a partial example of using both methods of X/Open standard
record locking.
Sharing Files and Locking Records 8–17
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......