Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

CTRecord.LockRecord

Syntax

void LockRecord(CTLOCK_MODE mode)

Parameters

Description

Locks the current record. In order to use this method, a record must be considered current. A record is set as the current record by update methods (Write()) or search methods (Find(), FindTarget(), First(), Next(), Prev(), Last(), SeekRecord()).

After a Record has been cleared (Clear()), no current record buffer is kept, and LockRecord() cannot be used. In this case, use the CTBase.Lock() method.

UnlockRecord() may be used to free the record lock. LockRecord(CTLOCK_FREE) has the same effect. Unlock() and Lock(CTLOCK_FREE) free all session wide locks but DO NOT free any records locked with LockRecord().

A record that is locked with one of the READ() locks available allows any other user with a READ() lock to read that record. No one can update one record using a READ() lock. When one user gets a WRITE() lock in a record, it means he/she may update that particular record, and until the record is freed, no one else is able to read that particular record.

Notice that LockRecord() should be called BEFORE modifying the record contents; otherwise, the changes will be lost.

When working with LockRecord(), the user must be certain to release the lock before moving to the next record or will need to use CTTable.UnlockTable() to release all record locks from a table at once. Do not mix the use of CTBase.Lock() and LockRecord() since an error DLOK_ERR (42), indicating record already locked, may occur.

Return

None.

See Also

CTBase.Lock(), UnlockRecord(), Locking

TOCIndex