Dbgetrk()
PURPOSE
get a data record by key
SYNPOSIS
#include "dbl.h" int dbgetrk(dbf, ndx, key, record, status) <input parameters> char *dbf; /* .DBF file descriptor */ char *ndx; /* .NDX file descriptor */ char *key; /* Address of a key buffer */ <output parameters> char *record; /* Address of a buffer where record's contents are stored */ char *status; /* Status of record: ACTIVE or INACTIVE */
RETURN VALUE
The dbgetrk() function returns 0 for success, or < 0 if an error occurs. See the section on return code values for a detailed list of failure codes.
DESCRIPTION
This function obtains a record from a .DBF file by key. First, the function looks for the specified key in the .NDX file and if found, obtains the corresponding record number. It then accesses the .DBF file directly by the record number and transfers the record to the user supplied buffer. The status of the record is returned in the user supplied variable.
EXAMPLE
This example reads a record from a .DBF file whose file descriptor is specified in "char *dbf" that matches the character key "021-70-9045", stores the contents of the record in the buffer "char record[1000]" and the status of the record in the variable "char status". The status is printed on the standard output.
#include "dbl.h" char *dbf; /* .DBF file descriptor */ char *ndx; /* .NDX file descriptor */ char key[20] = "021-70-9045"; /* Key */ char record[1000]; /* Record buffer */ char status; /* Status: ACTIVE or INACTIVE */ int rc; /* Return code */ rc = dbgetrk(dbf, ndx, key, record, &status); if (rc = = SUCCESS) { printf("The status of the record matching the key, %s is %d \n", key, status); } else { printf("error number %d \n", rc); exit (1); }
SEE ALSO
dbdcache(), dbdelete(), dbgather(), dbgetr(), dbscatter(), dbtkey()