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->dup()</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="dbcdel.html" title="DBcursor->del()" /> 12 <link rel="next" href="dbcget.html" title="DBcursor->get()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DBcursor->dup()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbcdel.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="dbcget.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="dbcdup"></a>DBcursor->dup()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DBcursor->dup(DBC *DBcursor, DBC **cursorp, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DBcursor->dup()</code> method creates a new cursor that uses the same 44 transaction and locker ID as the original cursor. This is useful when 45 an application is using locking and requires two or more cursors in 46 the same thread of control. 47 </p> 48 <p> 49 The <code class="methodname">DBcursor->dup()</code> <span> 50 <span> 51 method returns a non-zero error value on failure and 0 on success. 52 </span> 53 54 </span> 55 </p> 56 <div class="sect2" lang="en" xml:lang="en"> 57 <div class="titlepage"> 58 <div> 59 <div> 60 <h3 class="title"><a id="id1654310"></a>Parameters</h3> 61 </div> 62 </div> 63 </div> 64 <div class="sect3" lang="en" xml:lang="en"> 65 <div class="titlepage"> 66 <div> 67 <div> 68 <h4 class="title"><a id="id1654544"></a>cursorp</h4> 69 </div> 70 </div> 71 </div> 72 <p> 73 The <code class="methodname">DBcursor->dup()</code> method 74 returns the newly created cursor in 75 <span class="bold"><strong>cursorp</strong></span>. 76 </p> 77 </div> 78 <div class="sect3" lang="en" xml:lang="en"> 79 <div class="titlepage"> 80 <div> 81 <div> 82 <h4 class="title"><a id="id1654545"></a>flags</h4> 83 </div> 84 </div> 85 </div> 86 <p> 87 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 88 or the following flag: 89 </p> 90 <div class="itemizedlist"> 91 <ul type="disc"> 92 <li> 93 <p><a id="dup_DB_POSITION"></a> 94 <code class="literal">DB_POSITION</code> 95 </p> 96 <p> 97 The newly created cursor is initialized to refer to the same position 98 in the database as the original cursor (if any) and hold the same 99 locks (if any). If the DB_POSITION flag is not specified, or the 100 original cursor does not hold a database position and locks, the 101 created cursor is uninitialized and will behave like a cursor newly 102 created using the <a class="xref" href="dbcursor.html" title="DB->cursor()">DB->cursor()</a> 103 method. 104 </p> 105 </li> 106 </ul> 107 </div> 108 </div> 109 </div> 110 <div class="sect2" lang="en" xml:lang="en"> 111 <div class="titlepage"> 112 <div> 113 <div> 114 <h3 class="title"><a id="id1654660"></a>Errors</h3> 115 </div> 116 </div> 117 </div> 118 <p> 119 The <code class="methodname">DBcursor->dup()</code> <span> 120 <span> 121 method may fail and return one of the following non-zero errors: 122 </span> 123 124 </span> 125 </p> 126 <div class="sect3" lang="en" xml:lang="en"> 127 <div class="titlepage"> 128 <div> 129 <div> 130 <h4 class="title"><a id="id1654144"></a> DB_REP_HANDLE_DEAD</h4> 131 </div> 132 </div> 133 </div> 134 <p> 135 When a client synchronizes with the master, it is possible for committed 136 transactions to be rolled back. This invalidates all the database and cursor 137 handles opened in the replication environment. Once this occurs, an attempt to use 138 such a handle will 139 140 return <code class="literal">DB_REP_HANDLE_DEAD</code>. 141 The application will need to discard the handle and open a new one in order to 142 continue processing. 143 </p> 144 </div> 145 <div class="sect3" lang="en" xml:lang="en"> 146 <div class="titlepage"> 147 <div> 148 <div> 149 <h4 class="title"><a id="id1654145"></a>DB_REP_LOCKOUT</h4> 150 </div> 151 </div> 152 </div> 153 <p> 154 The operation was blocked by client/master synchronization. 155 </p> 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="id1654671"></a>EINVAL</h4> 162 </div> 163 </div> 164 </div> 165 <p> 166 An invalid flag value or parameter was specified. 167 </p> 168 </div> 169 </div> 170 <div class="sect2" lang="en" xml:lang="en"> 171 <div class="titlepage"> 172 <div> 173 <div> 174 <h3 class="title"><a id="id1654562"></a>Class</h3> 175 </div> 176 </div> 177 </div> 178 <p> 179 <a class="link" href="dbc.html" title="Chapter��3.�� The DBcursor Handle">DBcursor</a> 180 </p> 181 </div> 182 <div class="sect2" lang="en" xml:lang="en"> 183 <div class="titlepage"> 184 <div> 185 <div> 186 <h3 class="title"><a id="id1654556"></a>See Also</h3> 187 </div> 188 </div> 189 </div> 190 <p> 191 <a class="xref" href="dbc.html#dbclist" title="Database Cursors and Related Methods">Database Cursors and Related Methods</a> 192 </p> 193 </div> 194 </div> 195 <div class="navfooter"> 196 <hr /> 197 <table width="100%" summary="Navigation footer"> 198 <tr> 199 <td width="40%" align="left"><a accesskey="p" href="dbcdel.html">Prev</a>��</td> 200 <td width="20%" align="center"> 201 <a accesskey="u" href="dbc.html">Up</a> 202 </td> 203 <td width="40%" align="right">��<a accesskey="n" href="dbcget.html">Next</a></td> 204 </tr> 205 <tr> 206 <td width="40%" align="left" valign="top">DBcursor->del()��</td> 207 <td width="20%" align="center"> 208 <a accesskey="h" href="index.html">Home</a> 209 </td> 210 <td width="40%" align="right" valign="top">��DBcursor->get()</td> 211 </tr> 212 </table> 213 </div> 214 </body> 215</html> 216