Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking
stream on the file (UNLOCK ALL RECORDS). (On Tru64 UNIX and Windows NT
systems for indexed files only, there is no current record lock.)
When you access a shared file with ACCESS MODE IS SEQUENTIAL and use
manual record locking, the UNLOCK statement can cause you to violate either of
the following statements: ( 1 ) the REWRITE statement rule that states that the
last input-output statement executed before the REWRITE must be a READ or
START statement, or ( 2 ) the DELETE statement rule that states that the last
input/output statement executed before the DELETE statement must be a READ.
You must lock the record before it can be rewritten or deleted.
Releasing Locks on Deleted Records
In automatic record locking, the DELETE operation releases the lock on the
record. In manual record-locking mode, you can delete a record using the
DELETE statement but still retain a record lock. You must use the UNLOCK
ALL RECORDS statement to release the lock on a deleted record.
If a second stream attempts to access a deleted record that retains a lock, the
second stream will receive either a ‘‘record not found’’ exception or a hard lock
condition. (See Section 8.4.3 for information on hard lock conditions.)
On OpenVMS, If another stream attempts to REWRITE a deleted record for
which there is a retained lock, the type of exception that access stream receives
depends on its file organization. If the file organization is RELATIVE, the access
stream receives the ‘‘record locked’’ status. If the file organization is INDEXED,
the access stream succeeds (receives the success status).
In relative files, the lock is on the relative cell (record) and cannot be rewritten
until the lock is released. On indexed files, the lock is on the record’s file address
(RFA) of the deleted record, so a new record (with a new RFA) can be written to
the file.
♦
Bypassing a Record Lock
When you use manual record locking, you can apply a READ REGARDLESS or
START REGARDLESS statement to bypass any record lock that exists. READ
REGARDLESS reads the record and applies no locks to the record. START
REGARDLESS positions to the record and applies no locks to the record. If the
record is currently locked by another access stream, a soft record lock condition
can be detected by a USE procedure. (See Section 8.4.3 for information on soft
record locks.)
You use READ REGARDLESS or START REGARDLESS when: ( 1 ) a record is
locked against readers because the record is about to be written, but ( 2 ) your
access program needs the existing record regardless of the possible change in its
data.
Note
You should recognize that READ REGARDLESS and START
REGARDLESS are of limited usefulness. They can only reliably tell
the user whether a record exists with a given key value. They cannot
guarantee the current contents of the data in the record. You prevent
the use of READ REGARDLESS or START REGARDLESS at the file
protection level when you prevent readers from referencing the file.
You can use READ REGARDLESS and START REGARDLESS during
sequential file access to force the File Position Indicator.
8–22 Sharing Files and Locking Records
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......