Berkeley DB: DB->cursor
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btr ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++

# DB->cursor

`

###

    #include <db.h>

    int
    DB->cursor(DB *db,
        DB_TXN *txnid, DBC **cursorp, u_int32_t flags);

# Description

The DB->cursor function creates a cursor and copies a pointer to it into the memory referenced by cursorp.

A cursor is a structure used to provide sequential access through a database. This interface and its associated functions replaces the functionality provided by the seq function in previous releases of Berkeley DB.

If the file is being accessed under transaction protection, the txnid parameter is a transaction ID returned from txn_begin, otherwise, NULL. If transaction protection is enabled, cursors must be opened and closed within the context of a transaction, and the txnid parameter specifies the transaction context in which the cursor may be used.

The flags parameter must be set to 0.

In addition, the following value may be set by logically OR'ing it into the flags parameter:

DB_RMW
  Specify that the cursor will be used to update the database. This flag should only be set when the DB_INIT_CDB flag was specified to db_appinit.

The DB->cursor function returns the value of errno on failure, and 0 on success.

# Errors

If a fatal error occurs in Berkeley DB, the DB->cursor function may fail and return DB_RUNRECOVERY, at which point all subsequent database calls will also return DB_RUNRECOVERY.

The DB->cursor function may fail and return errno for any of the errors specified for the following Berkeley DB and C library functions: __ham_c_init(3), free(3), lock_id, malloc(3), memcpy(3), and memset(3).

In addition, the DB->cursor function may fail and return errno for the following conditions:

EINVAL
  An invalid flag value or parameter was specified.

# See Also

db_appexit, db_appinit, db_version, DB->close, DB->cursor, DB->del, DB->fd, DB->get, DB->join, db_open, DB->put, DB->stat, DB->sync, DBcursor->c_close, DBcursor->c_del, DBcursor->c_get and DBcursor->c_put.`