DbiAcqTableLock

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

DbiAcqTableLock

Return to chapter overview

C syntax

DBIResult DBIFN DbiAcqTableLock (hCursor, eLockType);

Delphi syntax

function DbiAcqTableLock (hCursor: hDBICur; eLockType: DBILockType): DBIResult stdcall;

Description

DbiAcqTableLock acquires a table-level lock on the table associated with the given cursor.

Parameters

hCursor                Type: hDBICur                (Input)
Specifies the cursor handle.

eLockType                Type: DBILockType                (Input)
Specifies the table lock type.

Usage

This function is used to prevent other users from updating a table. It can be used to ensure that the data read by the client application is the same data that is stored in the table at that specific moment.

This function is used to acquire a lock of higher precedence than the lock acquired when the cursor was opened. Locks acquired are owned by the session, not the cursor. If a lock cannot be obtained, an error is returned.

Redundant locks can be acquired on the table. For each lock acquired, a separate call to DbiRelTableLock is required to release it.

dBASE and FoxPro: If a READ lock is attempted, it is automatically upgraded to a WRITE lock.

Paradox: Both READ locks and WRITE locks can be acquired.

Access: Access tables are locked exclusively.

SQL: This function depends on the capabilities of the server. Some servers provide non-blocking table locks; others provide blocking table locks only; others don't provide table locking. If table locking is supported for the server but locks are not held across transactions, the lock is automatically reacquired after transaction commit. If the application requires a commit, it is responsible for insuring that the window of exposure between lock release and reacquisition has not impacted its consistency requirements. This function is provided to enable a degree of consistency with other drivers. It is recommended that transactions or transactions combined with explicit locking be used for SQL.

Completion state

Any cursor opened on a table can release locks placed by any cursor opened on that table within the same session. When the last cursor on the table is closed, the locks on the table are automatically released.

DbiResult

Meaning

DBIERR_NONE

The lock was acquired successfully.

DBIERR_INVALIDHNDL

The specified cursor handle is invalid or NULL.

DBIERR_LOCKED

The requested lock is not available.

DBIERR_TBLLOCKLIMIT

The lock limit has been reached.

See also

DbiRelTableLock, DbiIsTableLocked, DbiOpenLockList, DbiAcqPersistTableLock, DbiOpenTable