Db::get API Ref

#include <db_cxx.h>

int Db::get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags);

int Db::pget(DbTxn *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 Dbc::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 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.

Parameters
data flags key pkey txnid

Errors

The Db::get method may fail and throw DbException, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:


DB_REP_HANDLE_DEAD

DB_REP_LEASE_EXPIRED

DB_REP_LOCKOUT

DB_SECONDARY_BAD

EINVAL

If the requested item could not be returned due to undersized buffer, the Db::get method will fail and either return DB_BUFFER_SMALL or throw a DbMemoryException exception.

If a transactional database environment operation was selected to resolve a deadlock, the Db::get method will fail and either return DB_LOCK_DEADLOCK or throw a DbDeadlockException exception.

If a Berkeley DB Concurrent Data Store database environment configured for lock timeouts was unable to grant a lock in the allowed time, the Db::get method will fail and either return DB_LOCK_NOTGRANTED or throw a DbLockNotGrantedException exception.

If the DB_CONSUME_WAIT flag was specified, lock or transaction timers were configured and the lock could not be granted before the wait-time expired, the Db::get method will fail and either return DB_LOCK_NOTGRANTED or throw a DbLockNotGrantedException exception.



Class Db
See Also Databases and Related Methods

APIRef

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