Difference between revisions of "Dbgetnr()"

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 */
  
 
<output parameters>
 
<output parameters>
char *record; /* Address of the buffer where record is returned */
+
char *record; /* Address of the buffer where record is returned */
char status; /* Record status: if record is marked for deletion,
+
char status; /* Record status: if record is marked for deletion, status is set to 0 (INACTIVE), otherwise it is set to 1 (ACTIVE) */
status is set to 0 (INACTIVE), otherwise
+
it is set to 1 (ACTIVE) */
+
  
 
</code>
 
</code>
Line 40: Line 38:
 
#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 record[1000]; /* Record buffer */
+
char record[1000]; /* Record buffer */
char status; /* Record status: ACTIVE or INACTIVE */
+
char status; /* Record status: ACTIVE or INACTIVE */
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc = dbgetnr(dbf, ndx, record, &status);
 
rc = dbgetnr(dbf, ndx, record, &status);
if (rc = = SUCCESS) printf("next record read n");
+
if (rc = = SUCCESS) printf("next record read \n");
 
else {
 
else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Revision as of 10:49, 1 May 2009

PURPOSE

get next data record by key


SYNOPSIS

#include "dbl.h"
 
	int	dbgetnr(dbf, ndx, record, status)
 
	<input parameters>
	char	*dbf;		/* .DBF file descriptor */
	char	*ndx;	/* .NDX file descriptor */
 
	<output parameters>
	char	*record;	/* Address of the buffer where record is returned */
	char	status;	/* Record status: if record is marked for deletion, status is set to 0 (INACTIVE), otherwise it is set to 1 (ACTIVE) */


RETURN VALUE

The dbgetnr() function returns 0 for success, or < 0 if an error occurs. See the section on return code values for a detailed list of return codes.


DESCRIPTION

This function sequentially reads a record in an ascending order. The first record number is obtained by reading the key to record number association table in the .NDX file. Then direct access of the .DBF file by record number is performed. After each sequential read operation, the access pointer to .NDX file is positioned at the next entry in the key to record number association table.


EXAMPLE

This example reads a record and its status from a .DBF file that is indexed one position after the current record.

#include "dbl.h"
 
	char	*dbf;			/* .DBF file descriptor */
	char	*ndx;		/* .NDX file descriptor */
	char	record[1000];	/* Record buffer */
	char	status;		/* Record status: ACTIVE or INACTIVE */
	int	rc;			/* Return code */
 
	rc = dbgetnr(dbf, ndx, record, &status);
	if (rc = = SUCCESS) printf("next record read \n");
	else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbckey(), dbdcache(), dbdelete(), dbgetpr(), dbgetr(), dbnkey()