dbm_fetch() — Get database content
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <ndbm.h>
datum dbm_fetch(DBM *db, datum key);
General description
The dbm_fetch() function reads a record from the database. The argument db is a handle to a database previously obtained by dbm_open(). The argument key is a datum that has been initialized by the application program to the value of the key that matches the key of the record the program is fetching. A datum is a structure that consists of two members, dptr and dsize. The member dptr is a char pointer to an array of data that is dsize bytes in length. (Note: The data is arbitrary binary data and is not NULL-terminated.)
The dptr is valid only until the next dbm_ operation by this thread.
Special behavior for z/OS® UNIX Services: In a multithreaded environment, the dbm_fetch() function returns a dptr in the datum structure to a data area that is thread-specific. This data area is not affected by other threads operations on the database, with the exception of a dbm_close() operation, which invalidates the datum.
Returned value
If successful, dbm_fetch() returns the datum containing a pointer to the data content dptr, and the data length dsize.
If unsuccessful, dbm_fetch() returns a NULL pointer in dptr and returns the error value in errno. Also, the database error indicator may be set.
Related information
- ndbm.h
- dbm_clearerr() — Clear database error indicator
- dbm_close() — Close a database
- dbm_delete() — Delete database record
- dbm_error() — Check database error indicator
- dbm_firstkey() — Get first key in database
- dbm_nextkey() — Get next key in database
- dbm_open() — Open a database
- dbm_store() — Store database record