RECORDLOCKL filevar, recID [ON ERROR statements] [LOCKED statements] RECORDLOCKU filevar, recID [ON ERROR statements] [LOCKED statements]
|filevar||A file variable name used to refer to a MultiValue file. This filevar is supplied by the OPEN statement.|
|recID||The record ID of a record to be locked, specified as an integer.|
The RECORDLOCK statements are used to lock a record in a MultiValue file.
RECORDLOCKL performs a shared lock on a record. It permits other users to also get a RECORDLOCKL on the record, but prevents other uses from getting a RECORDLOCKU on the record or an exclusive FILELOCK on the file.
RECORDLOCKU performs an update (exclusive) lock on a record. It prevents other uses from getting a RECORDLOCKL or RECORDLOCKU on the record or a FILELOCK of any type on the file.
The RECORDLOCK statements take the file identifier filevar, defined by the OPEN statement.
You can optionally specify a LOCKED clause. This clause is executed if the record to be locked has already been locked by another user. The clause is executed if the level of lock requested conflicts with an existing lock. This clause is optional, but strongly recommended; if no LOCKED clause is specified, program execution waits indefinitely for the conflicting lock to be released.
You can optionally specify an ON ERROR clause. If file lock fails, the ON ERROR clause is executed. This may occur if filevar does not refer to a currently open file.
You can check the status of file locks and record locks using the RECORDLOCKED function.
If you have a shared lock on a record, then request an exclusive (update) lock on the same record, MVBasic attempts to get the exclusive lock. If it is successful, your shared lock is promoted to an exclusive lock. The result is that you hold one exclusive lock, not two locks.
Releasing Record Locks
Use RELEASE to release individual record locks. CLOSE releases all record locks held on the specified file. ABORT and STOP release all record locks held by the current process.
An update record lock is automatically released when you write data to the record using WRITE or WRITEV. The WRITEU and WRITEVU commands do not release the update record lock.
An update record lock is automatically released when you delete the record using DELETE. The DELETEU command does not release the update record lock.