Difference between revisions of "Dbgetrk()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
char *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
char *key; /* Address of a key buffer */
+
char *key; /* Address of a key buffer */
  
 
<output parameters>
 
<output parameters>
char *record; /* Address of a buffer where record's contents are stored */
+
char *record; /* Address of a buffer where record's contents are stored */
char *status; /* Status of record: ACTIVE or INACTIVE */
+
char *status; /* Status of record: ACTIVE or INACTIVE */
  
 
</code>
 
</code>
Line 39: Line 39:
 
#include "dbl.h"
 
#include "dbl.h"
  
char *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
char key[20] = "021-70-9045"; /* Key */
+
char key[20] = "021-70-9045"; /* Key */
char record[1000]; /* Record buffer */
+
char record[1000]; /* Record buffer */
char status; /* Status: ACTIVE or INACTIVE */
+
char status; /* Status: ACTIVE or INACTIVE */
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc = dbgetrk(dbf, ndx, key, record, &status);
 
rc = dbgetrk(dbf, ndx, key, record, &status);
 
if (rc = = SUCCESS) {
 
if (rc = = SUCCESS) {
 
printf("The status of the record matching the key,
 
printf("The status of the record matching the key,
%s is %d n", key, status);
+
%s is %d \n", key, status);
 
} else {
 
} else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Revision as of 10:57, 1 May 2009

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()