The following code excerpt is an example of a UDF that calls the FNC_GetAnyTypeParamInfo function to retrieve information about the TD_ANYTYPE arguments.
#define SQL_TEXT Latin_Text #include "sqltypes_td.h" void ScalarFncWAnytype(void *input1, ..., void *result, char sqlstate[6]) { anytype_param_info_t paraminfo[2]; FNC_GetAnyTypeParamInfo(2*sizeof(anytype_param_info_t), &numAnyType, paraminfo); if(((paraminfo[1].datatype == CHAR_DT) || (paraminfo[1].datatype == VARCHAR_DT)) && (paraminfo[1].paramIndex == -1) && (paraminfo[1].direction == OUT_PM) && (paraminfo[1].charset == LATIN_CT)) { /* Process the value based upon the data type */ switch(paraminfo[0].datatype) { case BYTEINT_DT: strcpy ((char *)result,"Byteint"); break; /* Do some processing */ ... } } }
The following shows the corresponding SQL function definition:
REPLACE FUNCTION ScalarFncWAnytype ( p1 TD_ANYTYPE, ...) RETURNS TD_ANYTYPE NO SQL PARAMETER STYLE SQL RETURNS NULL ON NULL INPUT DETERMINISTIC LANGUAGE C EXTERNAL NAME 'CS!ScalarFncWAnytype!udfsrc/ScalarFncWAnytype.c';
For additional examples of functions that call FNC_GetAnyTypeParamInfo() to retrieve TD_ANYTYPE argument information, see C Scalar Function Using TD_ANYTYPE Parameters and C Aggregate Function Using TD_ANYTYPE Parameters.