|
Retrieving elements from a databaseThe simplest way to retrieve elements from a database is the DB->get interface. The DB->get interface takes the same five arguments that the DB->put interface takes:
Here's what the code to call DB->get looks like: #include <sys/types.h> #include <stdio.h> #include <db.h> It is not usually necessary to clear the DBT structures passed to the Berkeley DB functions between calls. This is not always true, when some of the less commonly used flags for DBT structures are used. The DBT manual page specified the details of those cases. It is possible, of course, to distinguish between system errors and the key/data pair simply not existing in the database. There are three standard returns from DB->get:
|