1<!--$Id: db_exists.so,v 1.1 2007/07/12 18:27:42 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DB->exists</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DB->exists</b> 14</td> 15<td align=right> 16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24int 25DB->exists(DB *db, DB_TXN *txnid, DBT *key, u_int32_t flags); 26</pre></b> 27<hr size=1 noshade> 28<b>Description: DB->exists</b> 29<p>The DB->exists method returns if the specified key appears in the 30database.</p> 31<p>The DB->exists method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a> if the specified key is not in the database. 32The DB->exists method will return <a href="../ref/program/errorret.html#DB_KEYEMPTY">DB_KEYEMPTY</a> if the database is a Queue or Recno database and 33the specified key exists, but was never explicitly created by the 34application or was later deleted. 35Unless otherwise specified, the DB->exists method 36returns a non-zero error value on failure 37and 0 on success. 38</p> 39<b>Parameters</b> <br> 40 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 41one of the following values: 42In addition, the following flags may be set by 43bitwise inclusively <b>OR</b>'ing them into the <b>flags</b> parameter: 44<br> 45<b><a name="DB_READ_COMMITTED">DB_READ_COMMITTED</a></b><ul compact><li>Configure a transactional read operation to have degree 2 isolation (the 46read is not repeatable).</ul> 47<b><a name="DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a></b><ul compact><li>Configure a transactional read operation to have degree 1 isolation, 48reading modified but not yet committed data. Silently ignored if the 49<a href="../api_c/db_open.html#DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a> flag was not specified when the underlying 50database was opened.</ul> 51<b><a name="DB_RMW">DB_RMW</a></b><ul compact><li>Acquire write locks instead of read locks when doing the read, if 52locking is configured. Setting this flag can eliminate deadlock during 53a read-modify-write cycle by acquiring the write lock during the read 54part of the cycle so that another thread of control acquiring a read 55lock for the same item, in its own read-modify-write cycle, will not 56result in deadlock. 57<p>Because the DB->exists method will not hold locks across 58Berkeley DB calls in non-transactional operations, the <a href="../api_c/dbc_get.html#DB_RMW">DB_RMW</a> flag to 59the DB->exists call is meaningful only in the presence of 60transactions.</p></ul> 61<br></ul> 62 <b>key</b><ul compact><li>The key <a href="../api_c/dbt_class.html">DBT</a> operated on.</ul> 63 <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the 64<b>txnid</b> parameter is a transaction handle returned from 65<a href="../api_c/txn_begin.html">DB_ENV->txn_begin</a>; if the operation is part of a Berkeley DB Concurrent Data Store group, the 66<b>txnid</b> parameter is a handle returned from 67<a href="../api_c/env_cdsgroup_begin.html">DB_ENV->cdsgroup_begin</a>; otherwise NULL. 68</ul> 69<br> 70<hr size=1 noshade> 71<br><b>Class</b> 72<a href="../api_c/db_class.html">DB</a> 73<br><b>See Also</b> 74<a href="../api_c/db_list.html">Databases and Related Methods</a> 75</tt> 76<table width="100%"><tr><td><br></td><td align=right> 77<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 78</td></tr></table> 79<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 80</body> 81</html> 82