Difference between revisions of "Dbgetpr()"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 43: Line 43:
  
 
rc = dbgetpr(dbf, ndx, record, &status);
 
rc = dbgetpr(dbf, ndx, record, &status);
if (rc = = SUCCESS) printf("previous record read \n");
+
if (rc == SUCCESS) printf("previous record read \n");
 
else {
 
else {
 
printf("error number %d \n", rc);
 
printf("error number %d \n", rc);

Latest revision as of 13:00, 1 May 2009

PURPOSE

get previous record by key


SYNOPSIS

#include "dbl.h"
 
	int	dbgetpr(dbf, ndx, record, status)
 
	<input parameters>
	char	*ndx;	/* .NDX file descriptor */
	char	*dbf;		/* .DBF file descriptor */
 
	<output parameters>
	char	*record;	/* User buffer where record contents are returned */
	char	status;	/* Status of record: ACTIVE or INACTIVE */


RETURN VALUE

The dbgetpr() 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 a descending (or counter alphabetical) order. First, the record number is obtained by reading the key to record number association table in the .NDX file. The direct access of .DBF file by record number is then performed. After each sequential read operation, the access pointer to .NDX file is positioned at the previous entry in the key to the record number association table.


EXAMPLE

#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 = dbgetpr(dbf, ndx, record, &status);
	if (rc == SUCCESS) printf("previous record read \n");
	else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbckey(), dbgetnr(), dbgetr(), dbpkey()