Difference between revisions of "Dbupdr()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 12: | Line 12: | ||
<input parameters> | <input parameters> | ||
− | char *dbf; | + | char *dbf; /* .DBF file descriptor */ |
− | long recno; /* Record number | + | long recno; /* Record number */ |
− | char *record; /* Address of the record buffer */ | + | char *record; /* Address of the record buffer */ |
<output parameters> | <output parameters> | ||
Line 42: | Line 42: | ||
#include "dbl.h" | #include "dbl.h" | ||
− | char *dbf; | + | char *dbf; /* .DBF file descriptor */ |
− | char new_records[20][100]; /* Contents of updated records*/ | + | char new_records[20][100]; /* Contents of updated records */ |
− | char old_record[100]; | + | char old_record[100]; /* Record to be updated */ |
− | char *status; | + | char *status; /* Status of record */ |
− | int i; | + | int i; /* Loop control variable */ |
− | int rc; | + | int rc; /* Return code */ |
for (i = = 1; i <= 20; ++i) { | for (i = = 1; i <= 20; ++i) { | ||
− | rc = dbgetr(dbf, i, record, &status); /* Get a record | + | rc = dbgetr(dbf, i, record, &status); /* Get a record */ |
if (rc !=SUCCESS) break; | if (rc !=SUCCESS) break; | ||
− | rc = dbupdr(dbf, i, new_records[i]); /* Update the record */ | + | rc = dbupdr(dbf, i, new_records[i]); /* Update the record */ |
if (rc != SUCCESS) break; | if (rc != SUCCESS) break; | ||
} | } |
Latest revision as of 16:03, 1 May 2009
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()