|
<< Click to Display Table of Contents >> C Examples: DbiPutField |
![]() ![]()
|
Example 1: Put the field value by field number.
This example uses the following input:
fDbiPutField1(hPXCur, pPXRecBuf, 1, (pBYTE)&DFloat);
DBIResult fDbiPutField1(hDBICur hTmpCur, pBYTE pTmpRecBuf, INT16 FldNum, pBYTE Info)
{
DBIResult rslt;
rslt = Chk(DbiPutField(hTmpCur, FldNum, pTmpRecBuf, Info));
return rslt;
}
Example 2: Put the field value specified by a field name..
If an invalid field name is given, an error is returned. This example uses the following input:
fDbiPutField2(hPXCur, pPXRecBuf, "STOCK NO", (pBYTE)&DFloat);
DBIResult fDbiPutField2(hDBICur hTmpCur, pBYTE pTmpRecBuf, pCHAR FldName, pBYTE Info)
{
DBIResult rslt;
CURProps CurProps;
pFLDDesc pFldDesc;
UINT16 Field;
BOOL Found = FALSE;
rslt = Chk(DbiGetCursorProps(hTmpCur, &CurProps));
if (rslt != DBIERR_NONE)
return rslt;
pFldDesc = (pFLDDesc)malloc(CurProps.iFields * sizeof(FLDDesc));
if (pFldDesc == NULL)
return DBIERR_NOMEMORY;
rslt = Chk(DbiGetFieldDescs(hTmpCur, pFldDesc));
if (rslt != DBIERR_NONE)
{
free(pFldDesc);
return rslt;
}
for(Field = 0; Field < CurProps.iFields; Field++)
{
if (strcmpi(pFldDesc[Field].szName, FldName) == 0)
{
Found = TRUE;
if (Info != NULL)
rslt = Chk(DbiPutField(hTmpCur, pFldDesc[Field].iFldNum, pTmpRecBuf, Info));
}
}
if (Found == FALSE)
rslt = DBIERR_INVALIDFIELDNAME;
free(pFldDesc);
return rslt;
}