Dbupdr()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

update record using record number


SYNOPSIS

#include "dbl.h"
 
	int	dbupdr(dbf, recno, record)
 
	<input parameters>
	char	*dbf;			/* .DBF file descriptor */
	long	recno;		/* Record number */
	char *record;		/* Address of the record buffer */
 
	<output parameters>
	none


RETURN VALUE

The dbupdr() 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 updates a record in a .DBF file, based on the given record number. The updated record is recognized as active. The corresponding .NDX file (if any) can be updated by dbrmvkey() followed by dbakey().


EXAMPLE

This example retrieves 20 records from a .DBF file whose file descriptor is in "char *dbf" and updates them with the contents of the character buffers specified in "char new_records[20][100]".


#include "dbl.h"
 
	char	*dbf;					/* .DBF file descriptor */
	char	new_records[20][100];		/* Contents of updated records */
	char	old_record[100];			/* Record to be updated */
	char	*status;				/* Status of record */
 
	int	i;					/* Loop control variable */
	int	rc;					/* Return code */
 
	for (i = = 1; i <= 20; ++i) {
		rc = dbgetr(dbf, i, record, &status);		/* Get a record */
		if (rc !=SUCCESS) break;
		rc = dbupdr(dbf, i, new_records[i]);		/* Update the record */
		if (rc != SUCCESS) break;
	}


SEE ALSO

dbakey(), dbappend(), dbflush(), dbgetr(), dbputr(), dbrmvkey()