Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <ndbm.h>
int dbm_store(DBM *db, datum key, datum content, int store_mode);
The dbm_store() function writes a record to a database. The db argument specifies the database handle returned by a previous call to dbm_open(). The key argument identifies the record the program is deleting. The key datum must contain a dptr pointer to the key, and the key length in dsize. The argument content is a datum. that describes the data record being stored. record the program is writing. The content datum. contains a dptr pointer to the data, and the data length in dsize.
After calling dbm_store(), during a pass through the keys by dbm_firstkey() and dbm_nextkey(), the application positioning must be reset by calling dbm_firstkey(). If not, unpredictable results may occur including retrieval of the same key multiple times, or not at all.
The number of records that can be stored in the database is limited by the file space available for the .dir and .pag files, and by the underlying key hashing. If multiple keys hash to the same 32 bit hash value, the number of keys for that hash value is limited to the amount of data (key sizes plus content sizes plus overhead) that can be stored in a single logical block of 1024 bytes.
Special behavior for z/OS® UNIX Services: In a multithreaded environment, changes made to the database by a dbm_store() operation affect all threads using the database handle. Thus, all other threads must also reset their positioning by using the dbm_firstkey() function before using dbm_nextkey(). A previously executed dbm_fetch() operation by another thread for the same key still has correct buffer pointers to the previous data. The dbm_store() operation does not affect this. All other operations, such as dbm_fetch() or dbm_delete(), will automatically have access to the new key and content pair.
If successful, dbm_store() returns 0. If DBM_INSERT is specified, and the key already exists, dbm_store() returns 1.