|
<< Click to Display Table of Contents >> C Examples: DbiSetRange |
![]() ![]()
|
Set the range for the specified cursor and return the amount of records in the range.
For this example to operate, the first field of the table must be numeric, such as STOCK.DB. This example uses the following input:
fDbiSetRange(hPXCur, &Count);
DBIResult fDbiSetRange(hDBICur hTmpCur, pUINT32 Count)
{
DBIResult rslt;
pBYTE pMinBuf, pMaxBuf;
DFLOAT key_min = 1000.00, key_max = 2000.00;
CURProps CurProps;
rslt = Chk(DbiGetCursorProps(hTmpCur, &CurProps));
if (rslt != DBIERR_NONE)
return rslt;
pMinBuf = (pBYTE)malloc(CurProps.iRecBufSize * sizeof(BYTE));
if (pMinBuf == NULL)
return DBIERR_NOMEMORY;
pMaxBuf = (pBYTE)malloc(CurProps.iRecBufSize * sizeof(BYTE));
if (pMaxBuf == NULL)
return DBIERR_NOMEMORY;
rslt = Chk(DbiPutField(hTmpCur, 1, pMinBuf, (pBYTE)&key_min));
if (rslt != DBIERR_NONE)
{
free(pMinBuf); free(pMaxBuf);
return rslt;
}
rslt = Chk(DbiPutField(hTmpCur, 1, pMaxBuf, (pBYTE)&key_max));
if (rslt != DBIERR_NONE)
{
free(pMinBuf); free(pMaxBuf);
return rslt;
}
rslt = Chk(DbiSetRange(hTmpCur, FALSE, 0, 0, (pBYTE)pMinBuf, FALSE,
0, 0, (pBYTE)pMaxBuf, TRUE));
*Count = 0L;
Chk(DbiGetRecordCount(hTmpCur, Count));
free(pMinBuf); free(pMaxBuf);
return rslt;
}