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_c/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 <db.h> 23<p> 24int 25DB->set_append_recno(DB *, 26 int (*db_append_recno_fcn)(DB *dbp, DBT *data, db_recno_t recno)); 27</pre></b> 28<hr size=1 noshade> 29<b>Description: DB->set_append_recno</b> 30<p>When using the <a href="../api_c/db_put.html#DB_APPEND">DB_APPEND</a> option of the <a href="../api_c/db_put.html">DB->put</a> method, 31it may be useful to modify the stored data based on the generated key. 32If a callback function is specified using the 33DB->set_append_recno method, it will be called after the record number 34has been selected, but before the data has been stored.</p> 35<p>The DB->set_append_recno method configures operations performed using the specified 36<a href="../api_c/db_class.html">DB</a> handle, not all operations performed on the underlying 37database.</p> 38<p>The DB->set_append_recno method may not be called after the <a href="../api_c/db_open.html">DB->open</a> method is called. 39</p> 40<p>The DB->set_append_recno method 41returns a non-zero error value on failure 42and 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_c/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_c/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_c/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 return one of the following non-zero errors:</p> 68<br> 69<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_c/db_open.html">DB->open</a> was called; or if an 70invalid flag value or parameter was specified.</ul> 71<br> 72<hr size=1 noshade> 73<br><b>Class</b> 74<a href="../api_c/db_class.html">DB</a> 75<br><b>See Also</b> 76<a href="../api_c/db_list.html">Databases and Related Methods</a> 77</tt> 78<table width="100%"><tr><td><br></td><td align=right> 79<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 80</td></tr></table> 81<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 82</body> 83</html> 84