Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Methods

Create

constructor Create(AOwner : TComponent);

The constructor for the TCtObject object.

Destroy

destructor Destroy();

The destructor for the TCtObject object. Do not call Destroy directly. The object has to be destroyed with the inherited (TObject) Free() method.

AbortTransaction

procedure AbortTransaction();

Abort the current transaction.

BeginTransaction

procedure BeginTransation();

Start a new transaction.

ClearError

procedure ClearError();

Clear the error code.

Commit Transaction

procedure CommitTransaction();

Commit the current transaction.

GetLockMode

function GetLockMode() : TCtLockMode;

Retrieve the current session-wide lock mode as given in “c-treeVCL/CLX Definitions”.

IsLockActive

function IsLockActive() : Boolean;

Verify the lock state, returning true if session wide locks are enabled.

IsTransActive

function IsTransActive() : Boolean;

Verify the transaction state. A transaction is activated by a call to BeginTransaction(), and deactivated with a call to CommitTransaction() or AbortTransaction().

Lock

procedure Lock(LockMode : CTLOCK_MODE);

Enable session lock. After a call to Lock, every record visited by Find(), First(), Last(), Next(), Prev() and Seek() will be locked. The valid lock modes are given in “c-treeVCL/CLX Definitions”.

Note: At the moment Lock is called, no file or record is locked. Instead, a flag is set internally to indicate that all new record reads will lock the records, with the given lock mode.

A READ lock on a record allows an unlimited number of READ locks on that record, but prevents WRITE locks. A WRITE lock prevents any other locks on that record.

Call Unlock or Lock with mode set to CTLOCK_FREE, to free all session locks. Notice that, if called inside a transaction, this free operation will result in the suspension of the locks, and not in their release. The locks will only be released when the transaction is finished with a call to CommitTransaction() or AbortTransaction(). If the locks are suspended, it means that new records read won't be locked. To restore the suspended locks, use Lock with one of the READ or WRITE lock modes (or the RESTORE options). If, for any special reason, the unused locks from a particular table must be released inside a transaction, the TCtTable procedure UnlockTable() may be used. Unused locks are records that where locked but not updated/deleted/added.

Note: Mixing LockRecord() and Lock() may result in DLOK_ERR (42) returns when an automatic lock is attempted on a manually locked record, or vice versa. DLOK_ERR (42) simply means a lock could not be obtained. In the example above, a locked record can't be re-locked.

RestoreSavePoint

procedure RestoreSavePoint(ASavePoint : TCtSavePoint);

Restore a transaction save point, given by ASavePoint. If ASavePoint is 0, the last save point is returned. If -1, the previous save point is returned, and so on.

SetSavePoint

function SetSavePoint() : TCtSavePoint;

Establish a transaction save point. The return of the function is the save point number that can be used to restore the save point.

Unlock

procedure Unlock();

Release all locks acquired by Lock.

Note: If called inside a transaction, this free operation suspends locks. The locks will only be released when the transaction is finished with a call to CommitTransaction() or AbortTransaction(). If the locks are suspended, it means that new records read won't be locked. To restore the suspended locks, use Lock with one of the READ or WRITE lock modes (or the RESTORE options). If, for any special reason, the unused locks from a particular table must be released inside a transaction, the TCtTable procedure UnlockTable() may be used. Unused locks are records that where locked but not updated/deleted/added.

TOCIndex