Command UNLOCK Foundation

Releases file and or record locks.

Syntax
UNLOCK [ALL]
UNLOCK [IN <nWorkArea> | <cAlias> ]
UNLOCK RECORD <xRecordId> [IN <nWorkArea> | <cAlias> ]
Parameters
ALL
The option ALL releases all file and record locks in all work areas. Without this option, only the locks in the current work area are released.
IN <nWorkArea>
<nWorkArea> is a positive integer specifying the ordinal number of the work area being selected.
IN <cAlias>
This argument is either a literal alias name or a character expression containing the alias name in parentheses. The alias name indicates the work area whose files are to be closed.
RECORD <xRecordID>
<xRecordID> is an optional record ID (for DBF files it is the record number). If specified, the record lock is released instead of the file lock.
Description

The command UNLOCK removes all existing record and file locks in the current work area or in the work area as specified using the IN clause. It is only significant when files are open in the SHARED mode. UNLOCK releases the locks without setting any new ones (as is done by the functions FLock() and RLock()).

The functions DbUnlock() and DbUnlockAll() are the functional equivalents of the command UNLOCK.

Examples
UNLOCK
// In the example, a record is locked before being 
// marked for deletion. When the record could be 
// locked, the record lock is released after the deletion. 

PROCEDURE Main 
   USE Customer ALIAS Cust NEW SHARED 
   GOTO 10 

   IF RLock() 
      DELETE 
      ? "Record No 10 is deleted" 
      UNLOCK 
   ELSE 
      ? "Record number 10 cannot be locked" 
   ENDIF 

   CLOSE Cust 
RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.