COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-270
UNLOCKRECORD
In Example 9-69, the UNLOCKFILE statement precedes a CLOSE statement to unlock
the file before the process closes it.
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.
Example 9-69. 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 file-name
VST231.vsd