Sharing Files and Locking Records
8.3 Ensuring Successful File Sharing
Figure 8–3 Why a Record-Already-Exists Error Occurs
Record 1
Record 2
Record 3
Record 4
End−of−File
Record 5/6
FILE A
ZK−6060−GE
Access Stream 1
Access Stream 2
When access stream 2 writes to the file, it also tries to write the fifth record.
Record 5 already exists (inserted by the first stream), and the second access
stream gets a record-exists error. Thus, in a file-sharing environment, the second
access stream always receives a record-exists error. To gain access to the current
highest relative record number, stream 2 must close the file and reopen it.
OPEN EXTEND with a Shared Indexed File
You must use the sequential file
access mode when you open an indexed file in extend mode. Sequential access
mode requires that the first additional record insertion have a prime record key
whose value is greater than the highest prime record key value in the file.
In a file-sharing environment, you should be aware of and prepared for duplicate
key errors (by using INVALID KEY and USE procedures), especially on the first
write to the file by the second access stream.
Subsequent writes should also allow for duplicate key errors, although subsequent
writes are not constrained to use keys whose values are greater than the highest
key value that existed at file open time. If you avoid duplicate key errors, you
will successfully insert all access stream records.
8.4 Ensuring Successful Record Locking
Once you meet all of the file-sharing criteria and you access a file, you can
consider two record-locking modes that control access to records in a file:
•
Automatic record locking—The system automatically releases an existing
record lock whenever a new record is accessed and acquires a record lock
whenever it reads a record in the file.
•
Manual record locking—A file connector can hold a number of record locks
simultaneously. Manual record locking is available only for relative or
indexed files.
Note
You must use the same method for record locking as for file sharing. For
any single file connector, you cannot mix the X/Open standard and the
Compaq standard methods.
8–16 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: ......