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>DBcursor->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="dbc.html" title="Chapter��3.�� The DBcursor Handle" /> 11 <link rel="prev" href="dbccount.html" title="DBcursor->count()" /> 12 <link rel="next" href="dbcdup.html" title="DBcursor->dup()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DBcursor->del()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbccount.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��3.�� 23 The DBcursor Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="dbcdup.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="dbcdel"></a>DBcursor->del()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DBcursor->del(DBC *DBcursor, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DBcursor->del()</code> method deletes the key/data pair to which the 44 cursor refers. 45 </p> 46 <p> 47 When called on a cursor opened on a database that has been made into a 48 secondary index using the 49 <a class="xref" href="dbassociate.html" title="DB->associate()">DB->associate()</a> method, the 50 <a class="xref" href="dbdel.html" title="DB->del()">DB->del()</a> method deletes 51 the key/data pair from the primary database and all secondary indices. 52 </p> 53 <p> 54 The cursor position is unchanged after a delete, and subsequent calls 55 to cursor functions expecting the cursor to refer to an existing key 56 will fail. 57 </p> 58 <p> 59 The <code class="methodname">DBcursor->del()</code> method will return <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_KEYEMPTY" class="olink">DB_KEYEMPTY</a> if 60 the element has already been deleted. The <code class="methodname">DBcursor->del()</code> 61 <span> 62 <span> 63 method returns a non-zero error value on failure and 0 on success. 64 </span> 65 66 </span> 67 </p> 68 <div class="sect2" lang="en" xml:lang="en"> 69 <div class="titlepage"> 70 <div> 71 <div> 72 <h3 class="title"><a id="id1653866"></a>Parameters</h3> 73 </div> 74 </div> 75 </div> 76 <div class="sect3" lang="en" xml:lang="en"> 77 <div class="titlepage"> 78 <div> 79 <div> 80 <h4 class="title"><a id="id1654226"></a>flags</h4> 81 </div> 82 </div> 83 </div> 84 <p> 85 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 86 or one of the following values: 87 </p> 88 <div class="itemizedlist"> 89 <ul type="disc"> 90 <li> 91 <p><a id="dbput_DB_CONSUME"></a> 92 <code class="literal">DB_CONSUME</code> 93 </p> 94 <p> 95 If the database is of type DB_QUEUE then this flag may be set to force the head of the queue 96 to move to the first non-deleted item in the queue. Normally this is only done if the 97 deleted item is exactly at the head when deleted. 98 </p> 99 </li> 100 </ul> 101 </div> 102 </div> 103 </div> 104 <div class="sect2" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h3 class="title"><a id="id1654372"></a>Errors</h3> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <code class="methodname">DBcursor->del()</code> <span> 114 <span> 115 method may fail and return one of the following non-zero errors: 116 </span> 117 118 </span> 119 </p> 120 <div class="sect3" lang="en" xml:lang="en"> 121 <div class="titlepage"> 122 <div> 123 <div> 124 <h4 class="title"><a id="id1654385"></a>DB_FOREIGN_CONFLICT</h4> 125 </div> 126 </div> 127 </div> 128 <p> 129 A <a class="link" href="dbassociate_foreign.html" title="DB->associate_foreign()">foreign key constraint violation</a> 130 has occurred. This can be caused by one of two things: 131 </p> 132 <div class="orderedlist"> 133 <ol type="1"> 134 <li> 135 <p> 136 An attempt was made to add a record to a 137 constrained database, and the key used for that 138 record does not exist in the foreign key 139 database. 140 </p> 141 </li> 142 <li> 143 <p> 144 <a class="link" href="dbassociate_foreign.html#associate_foreign_DB_FOREIGN_ABORT">DB_FOREIGN_ABORT</a> 145 was declared for a foreign key database, and then 146 subsequently a record was deleted from the 147 foreign key database without first removing it 148 from the constrained secondary database. 149 </p> 150 </li> 151 </ol> 152 </div> 153 </div> 154 <div class="sect3" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h4 class="title"><a id="id1654400"></a>DB_LOCK_DEADLOCK</h4> 159 </div> 160 </div> 161 </div> 162 <p> 163 A transactional database environment operation was selected to resolve 164 a deadlock. 165 </p> 166 </div> 167 <div class="sect3" lang="en" xml:lang="en"> 168 <div class="titlepage"> 169 <div> 170 <div> 171 <h4 class="title"><a id="id1654264"></a>DB_LOCK_NOTGRANTED</h4> 172 </div> 173 </div> 174 </div> 175 <p> 176 A Berkeley DB Concurrent Data Store database environment configured 177 for lock timeouts was unable to grant a lock in the allowed time. 178 </p> 179 </div> 180 <div class="sect3" lang="en" xml:lang="en"> 181 <div class="titlepage"> 182 <div> 183 <div> 184 <h4 class="title"><a id="id1654265"></a> DB_REP_HANDLE_DEAD</h4> 185 </div> 186 </div> 187 </div> 188 <p> 189 When a client synchronizes with the master, it is possible for committed 190 transactions to be rolled back. This invalidates all the database and cursor 191 handles opened in the replication environment. Once this occurs, an attempt to use 192 such a handle will 193 194 return <code class="literal">DB_REP_HANDLE_DEAD</code>. 195 The application will need to discard the handle and open a new one in order to 196 continue processing. 197 </p> 198 </div> 199 <div class="sect3" lang="en" xml:lang="en"> 200 <div class="titlepage"> 201 <div> 202 <div> 203 <h4 class="title"><a id="id1654409"></a>DB_REP_LOCKOUT</h4> 204 </div> 205 </div> 206 </div> 207 <p> 208 The operation was blocked by client/master synchronization. 209 </p> 210 </div> 211 <div class="sect3" lang="en" xml:lang="en"> 212 <div class="titlepage"> 213 <div> 214 <div> 215 <h4 class="title"><a id="id1654502"></a>DB_SECONDARY_BAD</h4> 216 </div> 217 </div> 218 </div> 219 <p> 220 A secondary index references a nonexistent primary key. 221 </p> 222 </div> 223 <div class="sect3" lang="en" xml:lang="en"> 224 <div class="titlepage"> 225 <div> 226 <div> 227 <h4 class="title"><a id="id1653232"></a>EACCES</h4> 228 </div> 229 </div> 230 </div> 231 <p> 232 An attempt was made to modify a read-only database. 233 </p> 234 </div> 235 <div class="sect3" lang="en" xml:lang="en"> 236 <div class="titlepage"> 237 <div> 238 <div> 239 <h4 class="title"><a id="id1653233"></a>EINVAL</h4> 240 </div> 241 </div> 242 </div> 243 <p> 244 If the cursor has not been initialized; or if an invalid flag value or parameter was specified. 245 </p> 246 </div> 247 <div class="sect3" lang="en" xml:lang="en"> 248 <div class="titlepage"> 249 <div> 250 <div> 251 <h4 class="title"><a id="id1654299"></a>EPERM</h4> 252 </div> 253 </div> 254 </div> 255 <p> 256 Write attempted on read-only cursor when the 257 <a class="link" href="envopen.html#envopen_DB_INIT_CDB">DB_INIT_CDB</a> 258 flag was specified to <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a>. 259 </p> 260 </div> 261 </div> 262 <div class="sect2" lang="en" xml:lang="en"> 263 <div class="titlepage"> 264 <div> 265 <div> 266 <h3 class="title"><a id="id1654300"></a>Class</h3> 267 </div> 268 </div> 269 </div> 270 <p> 271 <a class="link" href="dbc.html" title="Chapter��3.�� The DBcursor Handle">DBcursor</a> 272 </p> 273 </div> 274 <div class="sect2" lang="en" xml:lang="en"> 275 <div class="titlepage"> 276 <div> 277 <div> 278 <h3 class="title"><a id="id1654281"></a>See Also</h3> 279 </div> 280 </div> 281 </div> 282 <p> 283 <a class="xref" href="dbc.html#dbclist" title="Database Cursors and Related Methods">Database Cursors and Related Methods</a> 284 </p> 285 </div> 286 </div> 287 <div class="navfooter"> 288 <hr /> 289 <table width="100%" summary="Navigation footer"> 290 <tr> 291 <td width="40%" align="left"><a accesskey="p" href="dbccount.html">Prev</a>��</td> 292 <td width="20%" align="center"> 293 <a accesskey="u" href="dbc.html">Up</a> 294 </td> 295 <td width="40%" align="right">��<a accesskey="n" href="dbcdup.html">Next</a></td> 296 </tr> 297 <tr> 298 <td width="40%" align="left" valign="top">DBcursor->count()��</td> 299 <td width="20%" align="center"> 300 <a accesskey="h" href="index.html">Home</a> 301 </td> 302 <td width="40%" align="right" valign="top">��DBcursor->dup()</td> 303 </tr> 304 </table> 305 </div> 306 </body> 307</html> 308