beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 278

background image

Sharing Files and Locking Records
8.4 Ensuring Successful Record Locking

Example 8–7 (Cont.) Program Segment for Record-Locking Exceptions

IF record-locked

continue

ELSE

.
.
.

END-IF.

END DECLARATIVES.
MAIN-BODY SECTION.
BEGIN.

DISPLAY "From main-body".

.
.
.

GET-RECORD.

READ file-name.
IF NOT record-ok

PERFORM check-read.

.
.
.

CHECK-READ.

IF record-locked

MOVE 1 to retry-count
PERFORM retry-read UNTIL record-ok OR

retry-count > max-retry

IF record-locked AND retry-count > max-retry

DISPLAY "Record is unavailable...enter new record to retrieve: "

WITH NO ADVANCING

ACCEPT record-id
GO TO get-record

END-IF

END-IF.

* handle other possible errors here

RETRY-READ.

READ file-name.
add 1 to retry-count.

8–26 Sharing Files and Locking Records