COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 138 UNLOCKFILE Statement
FD IN-MASTER-FILE
...
PROCEDURE DIVISION.
...
IF UPDATE-FILE
OPEN INPUT IN-MASTER-FILE
LOCKFILE IN-MASTER-FILE
PERFORM UP-DATE-MASTER
UNTIL DONE
UNLOCKFILE IN-MASTER-FILE
CLOSE IN-MASTER-FILE
ELSE
...
UP-DATE-MASTER.
* Perform the update, during which time no other process
* can read any record in that file.
...
UNLOCKRECORD
UNLOCKRECORD restores access by other processes to the last record read (the record selected
by the file position indicator). The record was locked by execution of a READ LOCK statement.
file-name
is the file description name of a file.
Usage Considerations:
Action of the UNLOCKRECORD Statement
The UNLOCKRECORD statement affects only the record designated by the file position indicator
for the specified file; therefore, in normal use, it follows a successful read operation or a
successful read-then-rewrite sequence. A successful UNLOCKRECORD statement releases the
exclusive record-access guarantee obtained by a previously executed READ LOCK statement.
If the record is not locked, no error occurs.
UNLOCKRECORD Statement Immediately After START Statement
If an UNLOCKRECORD statement is the first input-output statement after a START statement,
a run-time error occurs.
File-Status Data Item
If file-name has an associated file-status data item, execution of the UNLOCKRECORD
statement always assigns an appropriate I-O status code as its value. The status “00” reports
a successful UNLOCKRECORD operation.
Whenever the statement terminates with an I-O status code greater than or equal to “30,
execution of the UNLOCKRECORD failed. The possible I-O status codes for an unsuccessful
UNLOCKRECORD operation are:
Unsuccessful UNLOCKFILE OperationI-O Status Code
The unlock operation failed due to non-COBOL causes. The record might or might not now
be unlocked.
“30”
The file was not open.“42”
UNLOCKRECORD 473