Berkeley DB Reference Guide: Retrieving records with a cursor
Berkeley DB Reference Guide:
Access Methods
Retrieving records with a cursor
The DBcursor->c_get function is the standard interface for retrieving records from
the database with a cursor. The DBcursor->c_get function takes a flag which
controls how the cursor is positioned within the database and returns the
key/data item associated with that positioning. Similar to
DB->get, DBcursor->c_get may also take a supplied key and retrieve
the data associated with that key from the database. There are several
flags that you can set to customize retrieval.
Return the record from the database that matches the supplied key. In
the case of duplicates the first duplicate is returned and the cursor
is positioned at the beginning of the duplicate list. The user can then
traverse the duplicate entries for the key.
Return the smallest record in the database greater than or equal to the
supplied key. This functionality permits partial key matches and range
searches in the Btree access method.
Return the record from the database that matches both the supplied key
and data items. This is particularly useful when there are large
numbers of duplicate records for a key, as it allows the cursor to
easily be positioned at the correct place for traversal of some part of
a large set of duplicate records.
If the underlying database is a Btree, and was configured so that it is
possible to search it by logical record number, retrieve a specific
record based on a record number argument.
If the underlying database is a Btree, and was configured so that it is
possible to search it by logical record number, return the record number
for the record referenced by the cursor.
Read-modify-write: acquire write locks instead of read locks during
retrieval. This can enhance performance in threaded applications by
reducing the chance of deadlock.
In all cases, the cursor is repositioned by a DBcursor->c_get operation
to point to the newly-returned key/data pair in the database.