Dbputrk()

From Recital Documentation Wiki
Revision as of 10:06, 2 April 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

put data record into a .DBF file by key


SYNOPSIS

#include "dbl.h"
 
	int	dbputrk(dbf, ndx, key, record)
 
	<input parameters>
	char	*dbf;		/* .DBF file descriptor	*/
	char	*ndx;		/* .NDX file descriptor	*/
	char	*key;		/* Key buffer			*/
	char	*record;	/* Record buffer		*/
 
	<output parameters>
	none


RETURN VALUE

The dbputrk() 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 adds a key to a .NDX file and its associated record to a .DBF file. First the function checks if the specified key already exists in the .NDX file. If it does, its associated record number is obtained and the record is written to the .DBF file. If not, the key is added to the .NDX file first and then the record is written to the end of the .DBF file.


EXAMPLE

This example adds a record whose contents are in "char record[100]" to the .DBF file whose file descriptor is in "char *dbf". It also indexes the file with the contents of "char key[8]" which is written to the file specified in "char *ndx".

#include "dbl.h"
 
	char	*dbf;			/* .DBF file descriptor	*/
	char	*ndx;			/* .NDX file descriptor	*/
	char	key[8];			/* Key buffer			*/
	char	record[100];		/* Record buffer		*/
	int	rc;			/* Return code			*/
 
	rc = dbputrk(dbf, ndx, key, record);
	if (rc = = SUCCESS) printf("record added n");
	else {
		printf("error number %d n", rc);
		exit (1)
	}


SEE ALSO

dbappend(), dbicreat(), dbiflsh(), dbputr()