Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions pageOpens in a new window (login required).


Returns the lock status for a record or file.




filevar A file variable name used to refer to a MultiValue file. This filevar is supplied by the OPEN statement. filevar must be specified as a literal.
recID The record ID of the record to be checked for lock status. An expression that resolves to an integer.


The RECORDLOCKED function returns an integer code specifying the lock status of the specified record or file. The following are the return codes:

3 This user has a file lock (shared or exclusive).
2 This user has an update record lock.
1 This user has a shared record lock.
0 This record is not locked.
-1 Another user has a shared record lock.
-2 Another user has an update record lock.
-3 Another user has a file lock (shared or exclusive).

If the specified file has both a file lock and a record lock, RECORDLOCKED returns the record lock code.

Invoking the RECORDLOCKED function sets the STATUS function to the job number of the job that holds the lock. If the lock is a shared lock, STATUS returns the job number of the first job found. If the current user shares the lock with another user, STATUS returns the other user's job.

File and Record Locking and Unlocking

To lock a file, use the FILELOCK statement. To unlock a file, use the FILEUNLOCK statement.

To lock a record, use the RECORDLOCKU (update lock) or RECORDLOCKL (shared lock) statement. To unlock a record, use the RELEASE statement.

See Also

FeedbackOpens in a new window