Difference between revisions of "Dbrecin()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(One intermediate revision by one user not shown)
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
char *dbffd; /* Database file descriptor */
+
char *dbffd; /* Database file descriptor */
dBFIELD fields; /* Array of record fields */
+
dBFIELD fields; /* Array of record fields */
int *fldpos; /* Array of field offsets */
+
int *fldpos; /* Array of field offsets */
char *buffer; /* Address of a buffer where record
+
char *buffer; /* Address of a buffer where record starts */
starts */
+
char fldbuffer[128][256]; /* Address of a buffer from which to update the record */
char fldbuffer[128][256]; /* Address of a buffer from which to update the record */
+
  
 
<output parameters>
 
<output parameters>
Line 31: Line 30:
 
==DESCRIPTIOIN==
 
==DESCRIPTIOIN==
  
The dbrecin() function fills component fields in a record from the individual field buffers specified.  The "fields" and "fldpos" are provided by The dbgetfx() function.  This provides a simple mechanism for transferring data to and from records with the use of [[dbputr()]].  If the individual field buffer is shorter than the expected length of the field, [[dbrecin()]] will pad with the appropriate blank spaces to the left.
+
The dbrecin() function fills component fields in a record from the individual field buffers specified.  The "fields" and "fldpos" are provided by The dbgetfx() function.  This provides a simple mechanism for transferring data to and from records with the use of [[dbputr()]].  If the individual field buffer is shorter than the expected length of the field, dbrecin() will pad with the appropriate blank spaces to the left.
  
  
Line 41: Line 40:
 
#include "dbl.h"
 
#include "dbl.h"
  
int nfields; /* Number of fields */
+
int nfields; /* Number of fields */
dBFIELD fields[128]; /* Return code */
+
dBFIELD fields[128]; /* Return code */
int fieldpos[128]; /* Field positions */
+
int fieldpos[128]; /* Field positions */
char record[1000]; /* Record buffer */
+
char record[1000]; /* Record buffer */
char fieldbuf[128][256]; /* Field buffers */
+
char fieldbuf[128][256]; /* Field buffers */
  
 
rc = dbrecin(nfields, fields, fieldpos, record, fieldbuf);
 
rc = dbrecin(nfields, fields, fieldpos, record, fieldbuf);
if (rc = = SUCCESS) printf("record filled n");
+
if (rc == SUCCESS) printf("record filled \n");
 
else {
 
else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Latest revision as of 14:22, 1 May 2009

PURPOSE

fill a single record buffer from field buffers


SYNOPSIS

#include "dbl.h"
 
	int	dbrecin(dbf, fields, fldpos, buffer, fldbuffer)
 
	<input parameters>
	char		*dbffd;			/* Database file descriptor */
	dBFIELD	fields;			/* Array of record fields */
	int		*fldpos;			/* Array of field offsets	 */
	char		*buffer;			/* Address of a buffer where record starts */
	char		fldbuffer[128][256];	/* Address of a buffer from which to update the record */
 
	<output parameters>
	none


RETURN VALUE

The dbrecin() 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.


DESCRIPTIOIN

The dbrecin() function fills component fields in a record from the individual field buffers specified. The "fields" and "fldpos" are provided by The dbgetfx() function. This provides a simple mechanism for transferring data to and from records with the use of dbputr(). If the individual field buffer is shorter than the expected length of the field, dbrecin() will pad with the appropriate blank spaces to the left.


EXAMPLE

This example fills the buffer record with field data stored in "char fieldbuf".

#include "dbl.h"
 
	int		nfields;			/* Number of fields */
	dBFIELD	fields[128];		/* Return code */
	int		fieldpos[128];		/* Field positions */
	char		record[1000];		/* Record buffer */
	char		fieldbuf[128][256];	/* Field buffers */
 
	rc = dbrecin(nfields, fields, fieldpos, record, fieldbuf);
	if (rc == SUCCESS) printf("record filled \n");
	else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbgather(), dbgetfx(), dbputr(), dbrecout(), dbrecout()