Partager via


UNLOCK Command

Releases a record lock, multiple record locks, or a file lock from a table, or releases all record and file locks from all open tables.

UNLOCK    [RECORD nRecordNumber]   [IN nWorkArea | cTableAlias]   [ALL]

Parameters

  • RECORD nRecordNumber
    Releases the record lock on record number nRecordNumber. You can specify 0 for nRecordNumber to unlock a table header locked with LOCK(0) or RLOCK(0).

    Issuing UNLOCK RECORD nRecordNumber for a record in a table with a file lock releases the file lock.

  • IN nWorkArea | cTableAlias
    Releases a record lock (or locks) or a file lock from a table in a specific work area. nWorkArea specifies a work area number and cTableAlias specifies a table alias. If you don't include nWorkArea or cTableAlias, UNLOCK releases a record lock (or locks) or a file lock from the table in the currently selected work area.

  • ALL
    Releases all record and file locks in all work areas.

    For more information about record and file locking and sharing tables on a network, see Programming for Shared Access.

Remarks

Record and file locks can be removed from a table only by the user who issued the locks. UNLOCK cannot unlock a table opened for exclusive use.

A record lock (or locks) or a file lock is released from the table in the current work area if you issue UNLOCK without any additional arguments.

If relations are established between tables, releasing a record lock (or locks) or a file lock from one of the tables doesn't release locks from the related records or files. You must explicitly release the record or file locks in each of the related files. You can release all locks on any related tables by issuing UNLOCK ALL (this also releases locks in unrelated files).

Example

CLOSE DATABASES
SET REPROCESS TO 3 AUTOMATIC
STORE '1,2,3,4' TO gcRecList     && Lock records 1 through 4
gcOldExc = SET('EXCLUSIVE')     && Save the EXCLUSIVE setting
SET EXCLUSIVE OFF  && Allow sharing of tables

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer  && Opens Customer table
SELECT 0
USE employee  && Opens Employee table

? LOCK('1,2,3,4', 'customer')  && Lock the first 4 records in customer
? RLOCK(gcRecList, 'employee') && Lock the first 4 records in employee

UNLOCK IN customer
UNLOCK IN employee
SET EXCLUSIVE &gcOldExc  && Restore original EXCLUSIVE setting

See Also

FLOCK( ) | LOCK( ) | RLOCK( ) | Programming for Shared Access