Dbc::put |
#include <db_cxx.h>int Dbc::put(Dbt *key, Dbt *data, u_int32_t flags);
The Dbc::put method stores key/data pairs into the database.
Unless otherwise specified, the Dbc::put 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::put fails for any reason, the state of the cursor will be unchanged. If Dbc::put succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
In the case of the Recno access method, it is an error to specify DB_AFTER if the underlying Recno database was not created with the DB_RENUMBER flag. If the DB_RENUMBER flag was specified, a new key is created, all records after the inserted item are automatically renumbered, and the key of the new record is returned in the structure to which the key parameter refers. The initial value of the key parameter is ignored. See Db::open for more information.
The DB_AFTER flag may not be specified to the Queue access method.
The Dbc::put method will return DB_NOTFOUND if the current cursor record has already been deleted and the underlying access method is Hash.
In the case of the Recno access method, it is an error to specify DB_BEFORE if the underlying Recno database was not created with the DB_RENUMBER flag. If the DB_RENUMBER flag was specified, a new key is created, the current record and all records after it are automatically renumbered, and the key of the new record is returned in the structure to which the key parameter refers. The initial value of the key parameter is ignored. See Db::open for more information.
The DB_BEFORE flag may not be specified to the Queue access method.
The Dbc::put method will return DB_NOTFOUND if the current cursor record has already been deleted and the underlying access method is Hash.
The Dbc::put method will return DB_NOTFOUND if the current cursor record has already been deleted and the underlying access method is Hash.
If the underlying database supports duplicate data items, and if the key already exists in the database and a duplicate sort function has been specified, the inserted data item is added in its sorted location. If the key already exists in the database and no duplicate sort function has been specified, the inserted data item is added as the first of the data items for that key.
The DB_KEYFIRST flag may not be specified to the Queue or Recno access methods.
If the underlying database supports duplicate data items, and if the key already exists in the database and a duplicate sort function has been specified, the inserted data item is added in its sorted location. If the key already exists in the database, and no duplicate sort function has been specified, the inserted data item is added as the last of the data items for that key.
The DB_KEYLAST flag may not be specified to the Queue or Recno access methods.
The DB_NODUPDATA flag may not be specified to the Queue or Recno access methods.
The Dbc::put method may fail and throw DbException, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:
If a transactional database environment operation was selected to resolve a deadlock, the Dbc::put 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::put method will fail and either return DB_LOCK_NOTGRANTED or throw a DbLockNotGrantedException exception.
Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.