Attempts to lock a table record or records.

RLOCK([nWorkArea | cTableAlias] | [cRecordNumberList, nWorkArea
 | cTableAlias])


nWorkArea| cTableAlias

Specifies the work area number or table alias for a table open in another work area. If you don't specify a work area or alias, RLOCK( ) attempts to lock the current record in the table in the currently selected work area.


Specifies that RLOCK( ) attempts to lock multiple records. The character expression cRecordNumberList specifies one or more record numbers, separated by commas, that RLOCK( ) attempts to lock. For example, to attempt record locks on the first four records in a table, cRecordNumberList should contain 1, 2, 3, 4.

To lock multiple records, you must have SET MULTILOCKS on and you must include the work area number (nWorkArea) or alias (cTableAlias) of the table in which you attempt to lock multiple records.

You can also lock multiple records by moving the record pointer to the record you would like to lock, issuing RLOCK( ) or LOCK( ) and then repeating this process for additional records.

In Visual FoxPro, you can specify 0 as a record number. Specifying 0 lets you attempt to lock the table header.

Caution noteCaution

Keep the table header locked for as short a time as possible because other users cannot add records to the table when the table header is locked.

Release the table header lock with UNLOCK RECORD 0, UNLOCK, or UNLOCK ALL.

If all the records specified in cRecordNumberList are successfully locked, RLOCK( ) returns true (.T.). If one or more of the records specified in cRecordNumberList cannot be locked, RLOCK( ) returns false (.F.) and locks none of the records. In either case, existing record locks remain in place. Multiple record locking is an additive process — placing additional record locks doesn't release existing record locks.

From a performance perspective, it is always faster to lock the entire table than to lock even a small number of records.

Expand imageReturn Value

Expand imageRemarks

Expand imageExample

Expand imageSee Also