1<!--$Id: txn_prepare.so,v 10.35 2004/08/13 03:39:03 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DbTxn::prepare</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DbTxn::prepare</b>
14</td>
15<td align=right>
16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db_cxx.h&gt;
23<p>
24int
25DbTxn::prepare(u_int8_t gid[DB_XIDDATASIZE]);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DbTxn::prepare</b>
29<a name="2"><!--meow--></a>
30<p>The DbTxn::prepare method initiates the beginning of a two-phase commit.</p>
31<p>In a distributed transaction environment, Berkeley DB can be used as a local
32transaction manager.  In this case, the distributed transaction manager
33must send <i>prepare</i> messages to each local manager.  The local
34manager must then issue a DbTxn::prepare and await its successful
35return before responding to the distributed transaction manager.  Only
36after the distributed transaction manager receives successful responses
37from all of its <i>prepare</i> messages should it issue any
38<i>commit</i> messages.</p>
39<p>In the case of nested transactions, preparing the parent causes all
40unresolved children of the parent transaction to be committed.  Child
41transactions should never be explicitly prepared.  Their fate will be
42resolved along with their parent's during global recovery.</p>
43<p>The DbTxn::prepare method
44either returns a non-zero error value
45or throws an exception that encapsulates a non-zero error value on
46failure, and returns 0 on success.
47</p>
48<b>Parameters</b> <br>
49 <b>gid</b><ul compact><li>The <b>gid</b> parameter specifies the global transaction ID by which this
50transaction will be known.  This global transaction ID will be returned
51in calls to <a href="../api_cxx/txn_recover.html">DbEnv::txn_recover</a>, telling the application which global
52transactions must be resolved.</ul>
53<br>
54<hr size=1 noshade>
55<br><b>Class</b>
56<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/txn_class.html">DbTxn</a>
57<br><b>See Also</b>
58<a href="../api_cxx/txn_list.html">Transaction Subsystem and Related Methods</a>
59</tt>
60<table width="100%"><tr><td><br></td><td align=right>
61<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
62</td></tr></table>
63<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
64</body>
65</html>
66