<!--$Id: db_cursor.so,v 10.54 2007/05/31 18:52:36 bostic Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: Db::cursor</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <table width="100%"><tr valign=top> <td> <h3>Db::cursor</h3> </td> <td align=right> <a href="../../db46-devel-4.6.21/api_cxx/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a> <a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a></td> </tr></table> <hr size=1 noshade> <tt> <h3><pre> #include <db_cxx.h> <p> int Db::cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags); </pre></h3> <hr size=1 noshade> <h3>Description: Db::cursor</h3> <p>The Db::cursor method returns a created database cursor.</p> <p>Cursors may span threads, but only serially, that is, the application must serialize access to the cursor handle.</p> <p>The Db::cursor method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. </p> <h3>Parameters</h3> <dl compact> <dt><b>cursorp</b><dd>The <b>cursorp</b> parameter references memory into which a pointer to the allocated cursor is copied. <dt><b>flags</b><dd>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or more of the following values: <dl compact> <dt><a name="DB_READ_COMMITTED">DB_READ_COMMITTED</a><dd>Configure a transactional cursor to have degree 2 isolation. This ensures the stability of the current data item read by this cursor but permits data read by this cursor to be modified or deleted prior to the commit of the transaction for this cursor. <dt><a name="DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a><dd>Configure a transactional cursor to have degree 1 isolation. Read operations performed by the cursor may return modified but not yet committed data. Silently ignored if the <a href="../../db46-devel-4.6.21/api_cxx/db_open.html#DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a> flag was not specified when the underlying database was opened. <dt><a name="DB_WRITECURSOR">DB_WRITECURSOR</a><dd>Specify that the cursor will be used to update the database. The underlying database environment must have been opened using the <a href="../../db46-devel-4.6.21/api_cxx/env_open.html#DB_INIT_CDB">DB_INIT_CDB</a> flag. <dt><a name="DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a><dd>Configure a transactional cursor to operate with read-only <a href="../../db46-devel-4.6.21/ref/transapp/read.html">snapshot isolation</a>. For databases with the <a href="../../db46-devel-4.6.21/api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> flag set, data values will be read as they are when the cursor is opened, without taking read locks. This flag implicitly begins a transaction that is committed when the cursor is closed. Silently ignored if <a href="../../db46-devel-4.6.21/api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> not set on the underlying database or if a transaction is supplied in the <b>txnid</b> parameter. </dl> <dt><b>txnid</b><dd>Cursor operations are not automatically transaction-protected, even if the <a href="../../db46-devel-4.6.21/api_cxx/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> flag is specified to the <a href="../../db46-devel-4.6.21/api_cxx/env_set_flags.html">DbEnv::set_flags</a> or <a href="../../db46-devel-4.6.21/api_cxx/db_open.html">Db::open</a> methods. If cursor operations are to be transaction-protected, the <b>txnid</b> parameter must be a transaction handle returned from <a href="../../db46-devel-4.6.21/api_cxx/txn_begin.html">DbEnv::txn_begin</a>; otherwise, NULL. To transaction-protect cursor operations, cursors must be opened and closed within the context of a transaction, and the <b>txnid</b> parameter specifies the transaction context in which the cursor may be used. </dl> <h3>Errors</h3> <p>The Db::cursor method may fail and throw <a href="../../db46-devel-4.6.21/api_cxx/except_class.html">DbException</a>, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:</p> <dl compact> <dt>DB_REP_HANDLE_DEAD<dd>The database handle has been invalidated because a replication election unrolled a committed transaction. <dt>DB_REP_LOCKOUT<dd>The operation was blocked by client/master synchronization. </dl> <dl compact> <dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <hr size=1 noshade> <h3>Class</h3> <a href="../../db46-devel-4.6.21/api_cxx/dbc_class.html">Dbc</a> <h3>See Also</h3> <a href="../../db46-devel-4.6.21/api_cxx/dbc_list.html">Database Cursors and Related Methods</a> </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../../db46-devel-4.6.21/api_cxx/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a><a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a> </td></tr></table> <p><font size=1>Copyright (c) 1996,2007 Oracle. All rights reserved.</font> </body> </html>