1<!--$Id: db_set_append_recno.so,v 1.24 2006/05/17 20:47:46 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: Db::set_append_recno</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>Db::set_append_recno</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
25Db::set_append_recno(int (*db_append_recno_fcn)(DB *dbp, Dbt *data, db_recno_t recno));
26</pre></b>
27<hr size=1 noshade>
28<b>Description: Db::set_append_recno</b>
29<p>When using the <a href="../api_cxx/db_put.html#DB_APPEND">DB_APPEND</a> option of the <a href="../api_cxx/db_put.html">Db::put</a> method,
30it may be useful to modify the stored data based on the generated key.
31If a callback function is specified using the
32Db::set_append_recno method, it will be called after the record number
33has been selected, but before the data has been stored.</p>
34<p>The Db::set_append_recno method configures operations performed using the specified
35<a href="../api_cxx/db_class.html">Db</a> handle, not all operations performed on the underlying
36database.</p>
37<p>The Db::set_append_recno method may not be called after the <a href="../api_cxx/db_open.html">Db::open</a> method is called.
38</p>
39<p>The Db::set_append_recno method
40either returns a non-zero error value
41or throws an exception that encapsulates a non-zero error value on
42failure, and returns 0 on success.
43</p>
44<b>Parameters</b> <br>
45 <b>db_append_recno_fcn</b><ul compact><li>The <b>db_append_recno_fcn</b> parameter is a function to call after
46the record number has been selected but before the data has been stored
47into the database.  The function takes three parameters:
48<br>
49<b><b>db</b></b><ul compact><li>The <b>db</b> parameter is the enclosing database handle.</ul>
50<b><b>dbt</b></b><ul compact><li>The <b>dbt</b> parameter is the data <a href="../api_cxx/dbt_class.html">Dbt</a> to be stored.</ul>
51<b><b>recno</b></b><ul compact><li>The <b>recno</b> parameter is the generated record number.</ul>
52<br>
53<p>The called function may modify the data <a href="../api_cxx/dbt_class.html">Dbt</a>.  If the function
54needs to allocate memory for the <b>data</b> field, the <b>flags</b>
55field of the returned <a href="../api_cxx/dbt_class.html">Dbt</a> should be set to
56DB_DBT_APPMALLOC, which indicates that Berkeley DB should free the
57memory when it is done with it.</p>
58<p>The callback function must return 0 on success and <b>errno</b> or
59a value outside of the Berkeley DB error name space on failure.</p>
60<p>Berkeley DB is not re-entrant.  Callback functions should not attempt to make
61library calls (for example, to release locks or close open handles).
62Re-entering Berkeley DB is not guaranteed to work correctly, and the results
63are undefined.</p></ul>
64<br>
65<br><b>Errors</b>
66<p>The Db::set_append_recno method
67may fail and throw
68<a href="../api_cxx/except_class.html">DbException</a>,
69encapsulating one of the following non-zero errors, or return one of
70the following non-zero errors:</p>
71<br>
72<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_cxx/db_open.html">Db::open</a> was called; or if an
73invalid flag value or parameter was specified.</ul>
74<br>
75<hr size=1 noshade>
76<br><b>Class</b>
77<a href="../api_cxx/db_class.html">Db</a>
78<br><b>See Also</b>
79<a href="../api_cxx/db_list.html">Databases and Related Methods</a>
80</tt>
81<table width="100%"><tr><td><br></td><td align=right>
82<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>
83</td></tr></table>
84<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
85</body>
86</html>
87