int db::ObjectLock::try_lock ( const ObjectId _object_id,
ObjectLockMode  _mode,
ObjectLockDuration  _duration = DB_COMMIT_LOCK 
) [inline]

Lock a database table or row.

If a different table or row was locked previously, that lock will be released only after the new lock is granted.

If a lock cannot be granted, try_lock immediately returns DB_ELOCKED.

Parameters:
_object_id Table or row identifier.
_mode 
  • DB_LOCK_SHARED Obtain a shared lock.

    When applied to a table or row, a shared object allows other transactions to read, but not modify, the locked object. When applied to a transaction, a shared lock allows other transactions to access the database concurrently.

  • DB_LOCK_EXCLUSIVE Obtain an exclusive lock.

    When applied to a table or row, an exclusive lock prevents other transactions from reading or writing the locked object. When applied to a transaction, an exclusive lock prevents other transactions from starting until the current transaction is finished.

_duration 
Returns:
See also:
TableId, RowId


Copyright © 2005-2008 ITTIA®. All rights reserved.