ctdbIsFieldNumeric
Indicate if a field represents a numeric field type.
Declaration
CTBOOL ctdbIsFieldNumeric(CTHANDLE Handle)
Description
ctdbIsFieldNumeric() indicates if the field handle represents a field with a numeric value. The numeric field types are: CT_CHAR, CT_CHARU, CT_INT2, CT_INT2U, CT_INT4, CT_INT4U, CT_DATE, CT_TIME, CT_MONEY, CT_TIMES, CT_SFLOAT, CT_DFLOAT, CT_EFLOAT, CT_CURRENCY, CT_NUMBER, and CT_INT8.
Returns
ctdbIsFieldNumeric() returns YES if the field represents a numeric value and NO if the field does not represent a numeric value
Example
/* if fields hField1 and hField2 are numeric, add the values and store the result in hField1 */
if (ctdbIsFieldNumeric(hField1) && ctdbIsFieldNumeric(hField2))
{
CTNUMBER res, val1, val2;
ctdbGetFieldAsNumber(hRecord, ctdbGetFieldNbr(hField1), &val1);
ctdbGetFieldAsNumber(hRecord, ctdbGetFieldNbr(hField2), &val2);
ctdbNumberAdd(&val1, &val2, &res);
ctdbSetFieldAsNumber(hRecord, ctdbGetFieldNbr(hField1), &res);
}
See also
ctdbGetFieldNbr(), ctdbGetFieldProperties()