Dbc::get API Ref

#include <db_cxx.h>

int Dbc::get(Dbt *key, Dbt *data, u_int32_t flags);

int Dbc::pget(Dbt *key, Dbt *pkey, Dbt *data, u_int32_t flags);


Description: Dbc::get

The Dbc::get method retrieves key/data pairs from the database. The address and length of the key are returned in the object to which key refers (except for the case of the DB_SET flag, in which the key object is unchanged), and the address and length of the data are returned in the object to which data refers.

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

Modifications to the database during a sequential scan will be reflected in the scan; that is, records inserted behind a cursor will not be returned while records inserted in front of a cursor will be returned.

In Queue and Recno databases, missing entries (that is, entries that were never explicitly created or that were created and then deleted) will be skipped during a sequential scan.

Unless otherwise specified, the Dbc::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.

If Dbc::get fails for any reason, the state of the cursor will be unchanged.

Parameters
data flags key pkey

Errors

The Dbc::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 Dbc::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 Dbc::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 Dbc::get method will fail and either return DB_LOCK_NOTGRANTED or throw a DbLockNotGrantedException exception.



Class Dbc
See Also Database Cursors and Related Methods

APIRef

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