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_cxx/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 &lt;db_cxx.h&gt;
23<p>
24int
25Db::exists(DbTxn *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
36either returns a non-zero error value
37or throws an exception that encapsulates a non-zero error value on
38failure, and returns 0 on success.
39</p>
40<b>Parameters</b> <br>
41 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
42one of the following values:
43In addition, the following flags may be set by
44bitwise inclusively <b>OR</b>'ing them into the <b>flags</b> parameter:
45<br>
46<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
47read is not repeatable).</ul>
48<b><a name="DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a></b><ul compact><li>Configure a transactional read operation to have degree 1 isolation,
49reading modified but not yet committed data.  Silently ignored if the
50<a href="../api_cxx/db_open.html#DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a> flag was not specified when the underlying
51database was opened.</ul>
52<b><a name="DB_RMW">DB_RMW</a></b><ul compact><li>Acquire write locks instead of read locks when doing the read, if
53locking is configured.  Setting this flag can eliminate deadlock during
54a read-modify-write cycle by acquiring the write lock during the read
55part of the cycle so that another thread of control acquiring a read
56lock for the same item, in its own read-modify-write cycle, will not
57result in deadlock.
58<p>Because the Db::exists method will not hold locks across
59Berkeley DB calls in non-transactional operations, the <a href="../api_cxx/dbc_get.html#DB_RMW">DB_RMW</a> flag to
60the Db::exists call is meaningful only in the presence of
61transactions.</p></ul>
62<br></ul>
63 <b>key</b><ul compact><li>The key <a href="../api_cxx/dbt_class.html">Dbt</a> operated on.</ul>
64 <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the
65<b>txnid</b> parameter is a transaction handle returned from
66<a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>; if the operation is part of a Berkeley DB Concurrent Data Store group, the
67<b>txnid</b> parameter is a handle returned from
68<a href="../api_cxx/env_cdsgroup_begin.html">DbEnv::cdsgroup_begin</a>; otherwise NULL.
69</ul>
70<br>
71<hr size=1 noshade>
72<br><b>Class</b>
73<a href="../api_cxx/db_class.html">Db</a>
74<br><b>See Also</b>
75<a href="../api_cxx/db_list.html">Databases and Related Methods</a>
76</tt>
77<table width="100%"><tr><td><br></td><td align=right>
78<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
79</td></tr></table>
80<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
81</body>
82</html>
83