Compaq AAQ2G1FTK Marine Radio User Manual


 
Sharing Files and Locking Records
8.3 Ensuring Successful File Sharing
Figure 83 Why a Record-Already-Exists Error Occurs
Record 1
Record 2
Record 3
Record 4
EndofFile
Record 5/6
FILE A
ZK6060GE
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.
816 Sharing Files and Locking Records