<!--$Id: txn_prepare.so,v 10.35 2004/08/13 03:39:03 bostic Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbTxn::prepare</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>DbTxn::prepare</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 DbTxn::prepare(u_int8_t gid[DB_XIDDATASIZE]); </pre></h3> <hr size=1 noshade> <h3>Description: DbTxn::prepare</h3> <a name="2"><!--meow--></a> <p>The DbTxn::prepare method initiates the beginning of a two-phase commit.</p> <p>In a distributed transaction environment, Berkeley DB can be used as a local transaction manager. In this case, the distributed transaction manager must send <i>prepare</i> messages to each local manager. The local manager must then issue a DbTxn::prepare and await its successful return before responding to the distributed transaction manager. Only after the distributed transaction manager receives successful responses from all of its <i>prepare</i> messages should it issue any <i>commit</i> messages.</p> <p>In the case of nested transactions, preparing the parent causes all unresolved children of the parent transaction to be committed. Child transactions should never be explicitly prepared. Their fate will be resolved along with their parent's during global recovery.</p> <p>The DbTxn::prepare 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>gid</b><dd>The <b>gid</b> parameter specifies the global transaction ID by which this transaction will be known. This global transaction ID will be returned in calls to <a href="../../db46-devel-4.6.21/api_cxx/txn_recover.html">DbEnv::txn_recover</a>, telling the application which global transactions must be resolved. </dl> <hr size=1 noshade> <h3>Class</h3> <a href="../../db46-devel-4.6.21/api_cxx/env_class.html">DbEnv</a>, <a href="../../db46-devel-4.6.21/api_cxx/txn_class.html">DbTxn</a> <h3>See Also</h3> <a href="../../db46-devel-4.6.21/api_cxx/txn_list.html">Transaction Subsystem 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>