Data type constants

The Informix® ESQL/C sqltypes.h header file contains integer constants for both SQL and Informix® ESQL/C data types. Some Informix® ESQL/C library functions require data type constants as arguments. You can also compare these data type constants in dynamic SQL programs to determine the type of column that the DESCRIBE statement described. The Informix® ESQL/C code excerpt in the following figure compares the sqltype element of an sqlvar structure to a series of SQL data type constants to determine what types of columns a DESCRIBE statement returned.
Figure 1. Code excerpt with SQL data type constants
for (col = udesc->sqlvar, i = 0; i < udesc->sqld; col++, i++)
   {  
   switch(col->sqltype)
      {
      case SQLSMFLOAT:
      col->sqltype = CFLOATTYPE;
      break;

      case SQLFLOAT:
        col->sqltype = CDOUBLETYPE;
        break;

      case SQLMONEY:
      case SQLDECIMAL:
        col->sqltype = CDECIMALTYPE;
        break;

      case SQLCHAR:
        col->sqltype = CCHARTYPE;
        break;

      default:
        /*  The program does not handle INTEGER,
         *  SMALL INTEGER, DATE, SERIAL or other
         *  data types.  Do nothing if we see
         *  an unsupported type.
         */
        return;
        }

For more information about the use of data type constants with the DESCRIBE statement, see Determine SQL statements.