Dbgetr()

From Recital Documentation Wiki
Revision as of 10:54, 1 May 2009 by Yvonnemilne (Talk | contribs)

Jump to: navigation, search

PURPOSE

get database record using record number


SYNOPSIS

#include "dbl.h"
 
	int	dbgetr(dbf, recno, record, status)
 
	<input parameters>
	char	*dbf;		/* .DBF file descriptor */
	long	recno;	/* Record number */
 
	<output parameters>
	char	*record;	/* Address of the record buffer */
	char	*status;	/* Status of record: ACTIVE or INACTIVE */


RETURN VALUE

This 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

The function reads a record and its status from a data file. ACTIVE status means the record is not deleted, INACTIVE means that the record has been marked deleted but still exists physically. A disk-write failure (d_WTFAIL) can be returned by the function because when this function is called, the buffer contents may be written onto the disk first and then a portion of data containing the requested record is transferred to the main memory.


EXAMPLE

This example reads the 128th record from a .DBF file, whose file descriptor is in "char *dbf" and prints its status on the standard outputs.

#include "dbl.h"
 
	char	*dbf;			/* .DBF file descriptor */
	char	record[100];	/* Record buffer */
	char	status;		/* Record status */
	int	rc;			/* Return code */
 
	rc = dbgetr(dbf, 128, record, &status);
	if (rc = = SUCCESS) {
		switch (status) {
			case ACTIVE:
				printf("record 128 is active \n");
				break;
			case INACTIVE:
				printf("record 128 is marked deleted \n");
				break;
		}
	} else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbappend(), dbcreat(), dbdcache(), dbdelete(), dbflush(), dbgather(), dbgetf(), dbgetnr(), dbgetpr(), dbgetrk(), dbputr(), dbrecall(), dbrecout(), dbscatter(), dbupdr()