|
Retrieving records with a cursorThe DBcursor->c_get method is the standard interface for retrieving records from the database with a cursor. The DBcursor->c_get method 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. Cursor position flags
Retrieving specific key/data pairs
Retrieving based on record numbers
Special-purpose flags
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. The following is a code example showing a cursor walking through a database and displaying the records it contains to the standard output: int display(database) char *database; { DB *dbp; DBC *dbcp; DBT key, data; int close_db, close_dbc, ret; |