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