IBM® Informix® Client Software Development Kit, Version 3.50
What Is IBM Informix ESQL/C > Informix ESQL/C data types > Choosing data types for host variables >
Previous Page | Next Page | Contents | Index

IBM Informix ESQL/C Programmer’s Manual

Data Type Constants

The IBM 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 Figure 22 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 22. Code Excerpt Using 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 Determining SQL statements.

SQL Data Type Constants

Table 17 shows the SQL data type constants for the IBM Informix. Table 18 shows the SQL data type constants for the additional data types that are available with the IBM Informix.

Table 17. Constants for Informix® SQL Column Data Types
SQL Data Type Defined Constant Integer Value
CHAR SQLCHAR 0
SMALLINT SQLSMINT 1
INTEGER SQLINT 2
FLOAT SQLFLOAT 3
SMALLFLOAT SQLSMFLOAT 4
DECIMAL SQLDECIMAL 5
SERIAL SQLSERIAL 6
DATE SQLDATE 7
MONEY SQLMONEY 8
DATETIME SQLDTIME 10
BYTE SQLBYTES 11
TEXT SQLTEXT 12
VARCHAR SQLVCHAR 13
INTERVAL SQLINTERVAL 14
NCHAR SQLNCHAR 15
NVARCHAR SQLNVCHAR 16
INT8 SQLINT8 17
BIGSERIAL SQLBIGSERIAL 53
LVARCHAR SQLLVARCHAR 43
BOOLEAN SQLBOOL 45
BIGINT SQLINFXBIGINT 52
BIGSERIAL SQLBIGSERIAL 53

Table 18. Constants for Informix SQL Column Data Types That Are Specific to IBM Informix
SQL Data Type Defined Constant Integer Value
SET SQLSET 19
MULTISET SQLMULTISET 20
LIST SQLLIST 21
ROW SQLROW 22
Varying-length opaque type SQLUDTVAR 40
Fixed-length opaque type SQLUDTFIXED 41
SENDRECV
(client-side only)
SQLSENDRECV 44

Important:
The SENDRECV data type has an SQL constant but can only be used in an Informix ESQL/C program. You cannot define a database column as type SENDRECV.

ESQL/C Data Type Constants

You assign an IBM Informix ESQL/C data type to a host variable in an Informix ESQL/C program. The following table shows these constants.

Table 19. Constants for ESQL/C Host-Variable Data Types
ESQL/C Data Type Constant Integer Value
char CCHARTYPE 100
short int CSHORTTYPE 101
int4 CINTTYPE 102
long CLONGTYPE 103
float CFLOATTYPE 104
double CDOUBLETYPE 105
dec_t or decimal CDECIMALTYPE 107
fixchar CFIXCHARTYPE 108
string CSTRINGTYPE 109
date CDATETYPE 110
dec_t or decimal CMONEYTYPE 111
datetime or dtime_t CDTIMETYPE 112
ifx_loc_t or loc_t CLOCATORTYPE 113
varchar CVCHARTYPE 114
intrvl_t or interval CINVTYPE 115
char CFILETYPE 116
int8 CINT8TYPE 117
collection CCOLTYPE 118
lvarchar CLVCHARTYPE 119
fixed binary CFIXBINTYPE 120
var binary CVARBINTYPE 121
boolean CBOOLTYPE 122
row CROWTYPE 123

You can use these Informix ESQL/C data types as arguments for some of the functions in the Informix ESQL/C library. For example, both the rtypalign() and rtypmsize() functions require data type values as arguments.

X/Open Data Type Constants

If your programs conform to the X/Open standards (compile with the -xopen option), you must use the data type values that the following table shows. IBM Informix defines the constants for these values in the sqlxtype.h header file.

Table 20. Constants for Informix SQL Column Data Types in an X/Open Environment
SQL Data Type Defined Constant X/Open Integer Value
CHAR XSQLCHAR 1
DECIMAL XSQLDECIMAL 3
INTEGER XSQLINT 4
SMALLINT XSQLSMINT 5
FLOAT XSQLFLOAT 6


Send feedback | Information roadmap | Examples exchange | Troubleshooting

For the PDF version of this book, see Publications for the IBM Informix family of products.
For the release notes, documentation notes, and machine notes, see the Release Notes page.
timestamp Release date: November 2010