Berkeley DB: Db::exists
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++

Db::exists |

`

    #include <db_cxx.h>

    int
    Db::exists(DbTxn *txnid, Dbt *key, u_int32_t flags);

Description: Db::exists

The Db::exists method returns if the specified key appears in the database.

The Db::exists method will return DB_NOTFOUND if the specified key is not in the database. The Db::exists method will return DB_KEYEMPTY if the database is a Queue or Recno database and the specified key exists, but was never explicitly created by the application or was later deleted. Unless otherwise specified, the Db::exists method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Parameters
flags

- The flags parameter must be set to 0 or one of the following values: In addition, the following flags may be set by bitwise inclusively OR'ing them into the flags parameter:
  DB_READ_COMMITTED
  - Configure a transactional read operation to have degree 2 isolation (the read is not repeatable).
  DB_READ_UNCOMMITTED
  - Configure a transactional read operation to have degree 1 isolation, reading modified but not yet committed data. Silently ignored if the DB_READ_UNCOMMITTED flag was not specified when the underlying database was opened.
  DB_RMW
  - Acquire write locks instead of read locks when doing the read, if locking is configured. Setting this flag can eliminate deadlock during a read-modify-write cycle by acquiring the write lock during the read part of the cycle so that another thread of control acquiring a read lock for the same item, in its own read-modify-write cycle, will not result in deadlock.

    Because the Db::exists method will not hold locks across Berkeley DB calls in non-transactional operations, the DB_RMW flag to the Db::exists call is meaningful only in the presence of transactions.

key

- The key Dbt operated on.

txnid

- If the operation is part of an application-specified transaction, the txnid parameter is a transaction handle returned from DbEnv::txn_begin; if the operation is part of a Berkeley DB Concurrent Data Store group, the txnid parameter is a handle returned from DbEnv::cdsgroup_begin; otherwise NULL.

Class Db
See Also Databases and Related Methods`

Copyright (c) 1996,2008 Oracle. All rights reserved.