### DB->exists |

`

###

    #include <db.h>

    int
    DB->exists(DB *db, DB_TXN *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 returns a non-zero error value on failure and 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 DB_ENV->txn_begin; if the operation is part of a Berkeley DB Concurrent Data Store group, the txnid parameter is a handle returned from DB_ENV->cdsgroup_begin; otherwise NULL.

### Class

DB

### See Also

Databases and Related Methods`

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