Debian Codegraph @

docs/api_reference/CXX/dbdel.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Db::del()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
10 <link rel="up" href="db.html" title="Chapter 2.  The Db Handle" />
11 <link rel="prev" href="dbcreate.html" title="Db" />
12 <link rel="next" href="dberr.html" title="Db::err()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Db::del()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbcreate.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 2. 
26 The Db Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="dberr.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="dbdel"></a>Db::del()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 Db::del(DbTxn *txnid, Dbt *key, u_int32_t flags);</pre>
45 <p>
46 The <code class="methodname">Db::del()</code> method removes key/data pairs from the database. The
47 key/data pair associated with the specified <span class="bold"><strong>key</strong></span> is discarded from the database. In the
48 presence of duplicate key values, all records associated with the
49 designated key will be discarded.
50 </p>
51 <p>
52 When called on a database that has been made into a secondary index
53 using the <a class="xref" href="dbassociate.html" title="Db::associate()">Db::associate()</a> method, the
54 <code class="methodname">Db::del()</code> method deletes the key/data pair from the primary database
55 and all secondary indices.
56 </p>
57 <p>
58 The <code class="methodname">Db::del()</code> method will return <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a> if the specified key
59 is not in the database. The <code class="methodname">Db::del()</code> method will return <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_KEYEMPTY" class="olink">DB_KEYEMPTY</a> if the database is a
60 Queue or Recno database and the specified key exists, but was never explicitly created by
61 the application or was later deleted. Unless otherwise specified, the
62 <code class="methodname">Db::del()</code> <span>
63
64 <span>
65 method either returns a non-zero error value or throws an
66 exception that encapsulates a non-zero error value on
67 failure, and returns 0 on success.
68 </span>
69 </span>
70 </p>
71 <div class="sect2" lang="en" xml:lang="en">
72 <div class="titlepage">
73 <div>
74 <div>
75 <h3 class="title"><a id="idm1381400"></a>Parameters</h3>
76 </div>
77 </div>
78 </div>
79 <div class="sect3" lang="en" xml:lang="en">
80 <div class="titlepage">
81 <div>
82 <div>
83 <h4 class="title"><a id="idp4332848"></a>txnid</h4>
84 </div>
85 </div>
86 </div>
87 <p>
88 If the operation is part of an application-specified transaction, the
89 <span class="bold"><strong>txnid</strong></span> parameter is a transaction
90 handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>;
91 if the operation is part of a Berkeley DB Concurrent Data Store group, the
92 <span class="bold"><strong>txnid</strong></span> parameter is a handle returned
93 from <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a>;
94 otherwise NULL. If no transaction handle is specified, but the
95 operation occurs in a transactional database, the operation will be
96 implicitly transaction protected.
97 </p>
98 </div>
99 <div class="sect3" lang="en" xml:lang="en">
100 <div class="titlepage">
101 <div>
102 <div>
103 <h4 class="title"><a id="idm2188096"></a>key</h4>
104 </div>
105 </div>
106 </div>
107 <p>
108 The key <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> operated on.
109 </p>
110 </div>
111 <div class="sect3" lang="en" xml:lang="en">
112 <div class="titlepage">
113 <div>
114 <div>
115 <h4 class="title"><a id="idp3450752"></a>flags</h4>
116 </div>
117 </div>
118 </div>
119 <p>
120 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
121 or one of the following values:
122 </p>
123 <div class="itemizedlist">
124 <ul type="disc">
125 <li>
126 <p><a id="dbput_DB_CONSUME"></a>
127 <code class="literal">DB_CONSUME</code>
128 </p>
129 <p>
130 If the database is of type DB_QUEUE then this flag may be set to force the head of the queue
131 to move to the first non-deleted item in the queue. Normally this is only done if the
132 deleted item is exactly at the head when deleted.
133 </p>
134 </li>
135 <li>
136 <p><a id="del_DB_MULTIPLE"></a>
137 <code class="literal">DB_MULTIPLE</code>
138 </p>
139 <p>
140 Delete multiple data items using keys from the buffer to which the
141 <span class="bold"><strong>key</strong></span> parameter refers.
142 </p>
143 <p>
144 To delete records in bulk by key with the btree or hash access methods, construct a
145 bulk buffer in the <span class="bold"><strong>key</strong></span>
146 <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> using
147 <a class="xref" href="dbmultipledatabuilder.html" title="DbMultipleDataBuilder">DbMultipleDataBuilder</a>.
148 To delete records in bulk by record number, construct a bulk buffer in the
149 <span class="bold"><strong>key</strong></span>
150 <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> using
151 <a class="xref" href="dbmultiplerecnodatabuilder.html" title="DbMultipleRecnoDataBuilder">DbMultipleRecnoDataBuilder</a>
152 with a data size of zero.
153 </p>
154 <p>
155 A successful bulk delete operation is logically equivalent to a loop through each
156 key/data pair, performing a <a class="xref" href="dbdel.html" title="Db::del()">Db::del()</a> for each one.
157 </p>
158 <p>
159 See the <a class="xref" href="dbt.html#dbtlist" title="DBT and Bulk Operations">DBT and Bulk Operations</a> for more information on
160 working with bulk updates.
161 </p>
162 <p>
163 The <code class="literal">DB_MULTIPLE</code> flag may only be used alone.
164 </p>
165 </li>
166 <li>
167 <p><a id="del_DB_MULTIPLE_KEY"></a>
168 <code class="literal">DB_MULTIPLE_KEY</code>
169 </p>
170 <p>
171 Delete multiple data items using keys and data from the buffer to which the
172 <span class="bold"><strong>key</strong></span> parameter refers.
173 </p>
174 <p>
175 To delete records in bulk with the btree or hash access methods, construct a bulk
176 buffer in the <span class="bold"><strong>key</strong></span>
177 <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> using
178 <a class="xref" href="dbmultiplekeydatabuilder.html" title="DbMultipleKeyDataBuilder">DbMultipleKeyDataBuilder</a>.
179 To delete records in bulk with the recno or hash access methods, construct a bulk
180 buffer in the <span class="bold"><strong>key</strong></span>
181 <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> using
182 <a class="xref" href="dbmultiplerecnodatabuilder.html" title="DbMultipleRecnoDataBuilder">DbMultipleRecnoDataBuilder</a>.
183 </p>
184 <p>
185 See the <a class="xref" href="dbt.html#dbtlist" title="DBT and Bulk Operations">DBT and Bulk Operations</a> for more information on
186 working with bulk updates.
187 </p>
188 <p>
189 The <code class="literal">DB_MULTIPLE_KEY</code> flag may only be used alone.
190 </p>
191 </li>
192 </ul>
193 </div>
194 </div>
195 </div>
196 <div class="sect2" lang="en" xml:lang="en">
197 <div class="titlepage">
198 <div>
199 <div>
200 <h3 class="title"><a id="idp465120"></a>Errors</h3>
201 </div>
202 </div>
203 </div>
204 <p>
205 The <code class="methodname">Db::del()</code> <span>
206
207 <span>
208 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
209 exception, encapsulating one of the following non-zero errors, or return one
210 of the following non-zero errors:
211 </span>
212 </span>
213 </p>
214 <div class="sect3" lang="en" xml:lang="en">
215 <div class="titlepage">
216 <div>
217 <div>
218 <h4 class="title"><a id="idp2592168"></a>DB_FOREIGN_CONFLICT</h4>
219 </div>
220 </div>
221 </div>
222 <p>
223 A <a class="link" href="dbassociate_foreign.html" title="Db::associate_foreign()">foreign key constraint violation</a>
224 has occurred. This can be caused by one of two things:
225 </p>
226 <div class="orderedlist">
227 <ol type="1">
228 <li>
229 <p>
230 An attempt was made to add a record to a
231 constrained database, and the key used for that
232 record does not exist in the foreign key
233 database.
234 </p>
235 </li>
236 <li>
237 <p>
238 <a class="link" href="dbassociate_foreign.html#associate_foreign_DB_FOREIGN_ABORT">DB_FOREIGN_ABORT</a>
239 was declared for a foreign key database, and then
240 subsequently a record was deleted from the
241 foreign key database without first removing it
242 from the constrained secondary database.
243 </p>
244 </li>
245 </ol>
246 </div>
247 </div>
248 <div class="sect3" lang="en" xml:lang="en">
249 <div class="titlepage">
250 <div>
251 <div>
252 <h4 class="title"><a id="idp2478240"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
253 </div>
254 </div>
255 </div>
256 <p>
257 A transactional database environment operation was selected to resolve
258 a deadlock.
259 </p>
260 <p>
261 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
262 your Berkeley DB API is configured to throw exceptions.
263 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
264 </p>
265 </div>
266 <div class="sect3" lang="en" xml:lang="en">
267 <div class="titlepage">
268 <div>
269 <div>
270 <h4 class="title"><a id="idp1954888"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
271 </div>
272 </div>
273 </div>
274 <p>
275 A Berkeley DB Concurrent Data Store database environment configured
276 for lock timeouts was unable to grant a lock in the allowed time.
277 </p>
278 <p>
279 You attempted to open a database handle that is configured
280 for no waiting exclusive locking, but the exclusive lock could not be
281 immediately obtained. See
282 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
283 for more information.
284 </p>
285 <p>
286 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
287 your Berkeley DB API is configured to throw exceptions.
288 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
289 </p>
290 </div>
291 <div class="sect3" lang="en" xml:lang="en">
292 <div class="titlepage">
293 <div>
294 <div>
295 <h4 class="title"><a id="idp1807704"></a> <span>DbRepHandleDeadException or</span> DB_REP_HANDLE_DEAD</h4>
296 </div>
297 </div>
298 </div>
299 <p>
300 When a client synchronizes with the master, it is possible for committed
301 transactions to be rolled back. This invalidates all the database and cursor
302 handles opened in the replication environment. Once this occurs, an attempt to use
303 such a handle will
304 <span>
305 throw a <a class="xref" href="dbrephandledead.html" title="DbRepHandleDeadException">DbRepHandleDeadException</a> (if
306 your application is configured to throw exceptions), or
307 </span>
308 return <code class="literal">DB_REP_HANDLE_DEAD</code>.
309 The application will need to discard the handle and open a new one in order to
310 continue processing.
311 </p>
312 </div>
313 <div class="sect3" lang="en" xml:lang="en">
314 <div class="titlepage">
315 <div>
316 <div>
317 <h4 class="title"><a id="idp1781496"></a><span>DbDeadlockException or </span>DB_REP_LOCKOUT</h4>
318 </div>
319 </div>
320 </div>
321 <p>
322 The operation was blocked by client/master synchronization.
323 </p>
324 <p>
325 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
326 your Berkeley DB API is configured to throw exceptions.
327 Otherwise, <code class="literal">DB_REP_LOCKOUT</code> is returned.
328 </p>
329 </div>
330 <div class="sect3" lang="en" xml:lang="en">
331 <div class="titlepage">
332 <div>
333 <div>
334 <h4 class="title"><a id="idm545304"></a>DB_SECONDARY_BAD</h4>
335 </div>
336 </div>
337 </div>
338 <p>
339 A secondary index references a nonexistent primary key.
340 </p>
341 </div>
342 <div class="sect3" lang="en" xml:lang="en">
343 <div class="titlepage">
344 <div>
345 <div>
346 <h4 class="title"><a id="idp1092920"></a>EACCES</h4>
347 </div>
348 </div>
349 </div>
350 <p>
351 An attempt was made to modify a read-only database.
352 </p>
353 </div>
354 <div class="sect3" lang="en" xml:lang="en">
355 <div class="titlepage">
356 <div>
357 <div>
358 <h4 class="title"><a id="idp307416"></a>EINVAL</h4>
359 </div>
360 </div>
361 </div>
362 <p>
363 An invalid flag value or parameter was specified.
364 </p>
365 </div>
366 </div>
367 <div class="sect2" lang="en" xml:lang="en">
368 <div class="titlepage">
369 <div>
370 <div>
371 <h3 class="title"><a id="idp903376"></a>Class</h3>
372 </div>
373 </div>
374 </div>
375 <p>
376 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
377 </p>
378 </div>
379 <div class="sect2" lang="en" xml:lang="en">
380 <div class="titlepage">
381 <div>
382 <div>
383 <h3 class="title"><a id="idp591520"></a>See Also</h3>
384 </div>
385 </div>
386 </div>
387 <p>
388 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
389 </p>
390 </div>
391 </div>
392 <div class="navfooter">
393 <hr />
394 <table width="100%" summary="Navigation footer">
395 <tr>
396 <td width="40%" align="left"><a accesskey="p" href="dbcreate.html">Prev</a> </td>
397 <td width="20%" align="center">
398 <a accesskey="u" href="db.html">Up</a>
399 </td>
400 <td width="40%" align="right"> <a accesskey="n" href="dberr.html">Next</a></td>
401 </tr>
402 <tr>
403 <td width="40%" align="left" valign="top">Db </td>
404 <td width="20%" align="center">
405 <a accesskey="h" href="index.html">Home</a>
406 </td>
407 <td width="40%" align="right" valign="top"> Db::err()</td>
408 </tr>
409 </table>
410 </div>
411 </body>
412 </html>