Berkeley DB Reference Guide: Access Methods
Полезная информация

Berkeley DB Reference Guide: Access Methods

Storing records with a cursor

The DBcursor->c_put function is the standard function for storing records into the database, with a cursor. In general, the cursor put function takes a key and inserts the associated data into the database.

There are several flags that you can set to customize retrieval:

DB_AFTER
Create a new record, immediately after the record currently referenced by the cursor.

DB_BEFORE
Create a new record, immediately before the record currently referenced by the cursor.

DB_CURRENT
Replace the contents of the record currently referenced by the cursor.

DB_KEYFIRST
Create a new record, as the first of the duplicate records for the supplied key.

DB_KEYLAST
Create a new record, as the last of the duplicate records for the supplied key.

In all cases, the cursor is repositioned by a DBcursor->c_put operation to point to the newly inserted key/data pair in the database.