Difference between revisions of "DBF FETCH()"
Yvonnemilne (Talk | contribs) |
(No difference)
|
Latest revision as of 10:41, 30 March 2009
PURPOSE
Fetch a record from the current database
SYNONYM
api_dbf_fetch()
SYNOPSIS
#include "dbapi.h" int DBF_FETCH(inflag, forcond, whilecond, lock, position_indexes, direction) <input parameters> int *initflag; /* Address of a buffer containing initialize flag */ char *forcond; /* Address of a buffer containing a valid for condition */ char *whilecond; /* Address of a buffer containing a valid while condition */ int lock; /* Lock record for update */ int position_indexes; /* Reposition the indexes */ int direction; /* Direction of search */ <output parameters> none
DESCRIPTION
The DBF_FETCH() function will a record from the currently selected database.
If the contents initialize flag is set to 0 then the current record will be reread, otherwise the next record for the specified conditions will be read.
The fetch function moves the record pointer forwards or backwards in currently selected database. If the value of direction is 1 the record pointer is moved forward or backwards if the value is -1.
If a filter condition is set, the record pointer will skip over any records that do not match the filter condition.
Also a FOR condition can be specified with the DBF_FETCH() function. The record pointer will search in the direction specified until a record is found that matches the FOR condition or until the EOF or BOF is reached.
If a WHILE condition is specified then the DBF_FETCH() function will terminate when the specified condition is false.
If the value of lock is specified as 1, then the current record is unlocked and the next record fetched is locked. If the value is0, then the next record fetched is read without locking but the record buffer is purged if the database is shareable.
If the value of position_indexes is specified as 1, then all secondary indexes open on the current database are repositioned. This should be done when updates are to be performed.
The DBF_FETCH() function returns -1 if no more records are available.
EXAMPLE
The following example returns the number of records in the database that match the condition "ord_value.1000".
#include ,stdio.h> #include "dbapi.h" dbapi_dbf_fetch() { int nrecs; int initflag; int result; DBF_GOTO(API_TOP); nrecs=0; result = DBF_FETCH(&initflag, "ord_value.1000", NULL, 0, 1, 1); while (result >=0) { ++nrecs; result = DBF_FETCH(&initflag, "ord_value.1000", NULL, 0, 1, 1); } _retni(nrecs); }
SEE ALSO
DBF_DELETE(), DBF_DELETED(), DBF_FILTER(), DBF_GOTO(), DBF_LOCKR(), DBF_RECALL(), DBF_RECNO(), DBF_SEEK(), DBF_SKIP(), DBF_UNLOCKF(), DBF_UNLOCKR()