Difference between revisions of "Dbgetr()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(2 intermediate revisions by one user not shown)
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
char *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
long recno; /* Record number */
+
long recno; /* Record number */
  
 
<output parameters>
 
<output parameters>
char *record; /* Address of the record buffer */
+
char *record; /* Address of the record buffer */
char *status; /* Status of record: ACTIVE or INACTIVE */
+
char *status; /* Status of record: ACTIVE or INACTIVE */
  
 
</code>
 
</code>
Line 30: Line 30:
  
  
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.
+
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 [[Library Return Code Values|(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.
  
  
Line 40: Line 40:
 
#include "dbl.h"
 
#include "dbl.h"
  
char *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
char record[100]; /* Record buffer */
+
char record[100]; /* Record buffer */
char status; /* Record status */
+
char status; /* Record status */
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc = dbgetr(dbf, 128, record, &status);
 
rc = dbgetr(dbf, 128, record, &status);
if (rc = = SUCCESS) {
+
if (rc == SUCCESS) {
 
switch (status) {
 
switch (status) {
 
case ACTIVE:
 
case ACTIVE:
printf("record 128 is active n");
+
printf("record 128 is active \n");
 
break;
 
break;
 
case INACTIVE:
 
case INACTIVE:
printf("record 128 is marked deleted n");
+
printf("record 128 is marked deleted \n");
 
break;
 
break;
 
}
 
}
 
} else {
 
} else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Latest revision as of 13:00, 1 May 2009

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()