# Db::set_append_recno

`

###

    #include <db_cxx.h>

    int
    Db::set_append_recno(
        int (*db_append_recno_fcn)(DB *dbp, Dbt *data, db_recno_t recno));

# Description

When using the DB_APPEND option of the Db::put method, it may be useful to modify the stored data based on the generated key. If a callback method is specified using the Db::set_append_recno method, it will be called after the record number has been selected, but before the data has been stored. The callback function must return 0 on success and errno or a value outside of the Berkeley DB error name space on failure.

The called function must take three arguments: a reference to the enclosing database handle; the data Dbt to be stored; and the selected record number. The called function may then modify the data Dbt.

If the callback function needs to allocate memory for the data field, the flags field of the returned Dbt should be set to DB_DBT_APPMALLOC, which indicates that Berkeley DB should free the memory when it is done with it.

The Db::set_append_recno interface may be used only to configure Berkeley DB before the Db::open interface is called.

The Db::set_append_recno 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.

# Class

DbEnv

# See Also

DbEnv::close, DbEnv::err, DbEnv::errx DbEnv::open, DbEnv::remove, DbEnv::set_alloc, DbEnv::set_cachesize, DbEnv::set_data_dir, DbEnv::set_errcall, DbEnv::set_errfile, DbEnv::set_error_stream, DbEnv::set_errpfx, DbEnv::set_feedback, DbEnv::set_flags, DbEnv::set_paniccall, DbEnv::set_recovery_init, DbEnv::set_rpc_server, DbEnv::set_shm_key, DbEnv::set_tas_spins, DbEnv::set_tmp_dir, DbEnv::set_timeout, DbEnv::set_verbose, DbEnv::strerror and DbEnv::version.`

Copyright Sleepycat Software