1<!--$Id: db_del.so,v 10.51 2007/10/24 16:06:06 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-&gt;del</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-&gt;del</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 &lt;db.h&gt;
23<p>
24int
25DB-&gt;del(DB *db, DB_TXN *txnid, DBT *key, u_int32_t flags);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DB-&gt;del</b>
29<p>The DB-&gt;del method removes key/data pairs from the database.  The
30key/data pair associated with the specified <b>key</b> is discarded from
31the database.  In the presence of duplicate key values, all records
32associated with the designated key will be discarded.</p>
33<p>When called on a database that has been made into a secondary index
34using the <a href="../api_c/db_associate.html">DB-&gt;associate</a> method, the DB-&gt;del method deletes the
35key/data pair from the primary database and all secondary indices.</p>
36<p>The DB-&gt;del method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a> if the specified key is not in the database.
37The DB-&gt;del method will return <a href="../ref/program/errorret.html#DB_KEYEMPTY">DB_KEYEMPTY</a> if the database is a Queue or Recno database and
38the specified key exists, but was never explicitly created by the
39application or was later deleted.
40Unless otherwise specified, the DB-&gt;del method
41returns a non-zero error value on failure
42and 0 on success.
43</p>
44<b>Parameters</b> <br>
45 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
46 <b>key</b><ul compact><li>The key <a href="../api_c/dbt_class.html">DBT</a> operated on.</ul>
47 <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the
48<b>txnid</b> parameter is a transaction handle returned from
49<a href="../api_c/txn_begin.html">DB_ENV-&gt;txn_begin</a>; if the operation is part of a Berkeley DB Concurrent Data Store group, the
50<b>txnid</b> parameter is a handle returned from
51<a href="../api_c/env_cdsgroup_begin.html">DB_ENV-&gt;cdsgroup_begin</a>; otherwise NULL.
52If no transaction handle is
53specified, but the
54operation occurs in a transactional
55database,
56the operation will be implicitly transaction protected.
57</ul>
58<br>
59<br><b>Errors</b>
60<p>The DB-&gt;del method
61may fail and return one of the following non-zero errors:</p>
62<br>
63<b>DB_LOCK_DEADLOCK</b><ul compact><li>A transactional database environment operation was selected to resolve
64a deadlock.</ul>
65<b>DB_LOCK_NOTGRANTED</b><ul compact><li>A Berkeley DB Concurrent Data Store database environment configured for lock timeouts was unable
66to grant a lock in the allowed time.</ul>
67<br>
68<br>
69<b>DB_REP_HANDLE_DEAD</b><ul compact><li>The database handle has been invalidated because a replication election
70unrolled a committed transaction.</ul>
71<br>
72<br>
73<b>DB_REP_LOCKOUT</b><ul compact><li>The operation was blocked by client/master synchronization.</ul>
74<br>
75<br>
76<b>DB_SECONDARY_BAD</b><ul compact><li>A secondary index references a nonexistent primary key.</ul>
77<br>
78<br>
79<b>EACCES</b><ul compact><li>An attempt was made to modify a read-only database.</ul>
80<br>
81<br>
82<b>EINVAL</b><ul compact><li>An
83invalid flag value or parameter was specified.</ul>
84<br>
85<hr size=1 noshade>
86<br><b>Class</b>
87<a href="../api_c/db_class.html">DB</a>
88<br><b>See Also</b>
89<a href="../api_c/db_list.html">Databases and Related Methods</a>
90</tt>
91<table width="100%"><tr><td><br></td><td align=right>
92<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>
93</td></tr></table>
94<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
95</body>
96</html>
97