Compaq AAQ2G1FTK Marine Radio User Manual


 
Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking
Soft Record Locks and Declarative USE Procedures
If a soft record lock occurs, the values of the following variables for the current
file are undefined until the execution of any applicable Declarative USE procedure
is complete:
Record buffer
RELATIVE KEY
DEPENDING ON
These variables remain undefined if the Declarative USE procedure terminates
with an EXIT PROGRAM statement.
Hard Record Locks and File Position During Sequential Access
If a hard record lock condition occurs for a sequential READ statement, the file
position indicator is unaffected. If the application must continue reading records,
the following actions may be taken:
Compaq standard record locking
START or READ REGARDLESS may be used to bypass a hard record lock
(see Soft Record Locks).
X/Open standard record locking
For indexed and relative files, a START statement, with the appropriate
KEY clause, may be used to skip the record that is locked. Because X/Open
START statements do not detect or acquire a record lock, some file processing
may still be possible. However, users must be aware that this is not typical
sequential file processing, as not all records will be retrieved.
Error Handling Example
Example 8–7 is an example of processing locked record conditions.
Example 87 Program Segment for Record-Locking Exceptions
FILE-CONTROL.
SELECT file-name ASSIGN TO "fshare.dat"
FILE STATUS IS file-stat.
WORKING-STORAGE SECTION.
01 file-stat PIC XX.
88 record-ok VALUES "00", "02", "04".
88 record-locked VALUE "92".
01 RETRY-COUNT PIC 9(2).
01 MAX-RETRY pic 9(2) VALUE 10.
.
.
.
PROCEDURE DIVISION.
DECLARATIVES.
FILE-USE SECTION. USE AFTER STANDARD EXCEPTION PROCEDURE ON file-name.
FILE-ERR.
* need declaratives to trap condition, but let main code process it.
* invalid key clause does not apply
(continued on next page)
Sharing Files and Locking Records 825