DB->get API Ref

#include <db.h>

int DB->get(DB *db, DB_TXN *txnid, DBT *key, DBT *data, u_int32_t flags);

int DB->pget(DB *db, DB_TXN *txnid, DBT *key, DBT *pkey, DBT *data, u_int32_t flags);


Description: DB->get

The DB->get method retrieves key/data pairs from the database. The address and length of the data associated with the specified key are returned in the structure to which data refers.

In the presence of duplicate key values, DB->get will return the first data item for the designated key. Duplicates are sorted by insert order, except where this order has been overridden by cursor operations. Retrieval of duplicates requires the use of cursor operations. See DBcursor->get for details.

When called on a database that has been made into a secondary index using the DB->associate method, the DB->get and DB->pget methods return the key from the secondary index and the data item from the primary database. In addition, the DB->pget method returns the key from the primary database. In databases that are not secondary indices, the DB->pget method will always fail.

The DB->get method will return DB_NOTFOUND if the specified key is not in the database. The DB->get method will return DB_KEYEMPTY if the database is a Queue or Recno database and the specified key exists, but was never explicitly created by the application or was later deleted. Unless otherwise specified, the DB->get method returns a non-zero error value on failure and 0 on success.

Parameters
data flags key pkey txnid

Errors

The DB->get method may fail and return one of the following non-zero errors:


DB_BUFFER_SMALL

DB_LOCK_DEADLOCK DB_LOCK_NOTGRANTED

DB_LOCK_NOTGRANTED

DB_REP_HANDLE_DEAD

DB_REP_LEASE_EXPIRED

DB_REP_LOCKOUT

DB_SECONDARY_BAD

EINVAL


Class DB
See Also Databases and Related Methods

APIRef

Copyright (c) 1996,2008 Oracle. All rights reserved.