Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements > SET DESCRIPTOR >

Setting the TYPE or ITYPE Field

Use these integer values to set the value of TYPE or ITYPE for each item.

SQL Data Type Integer
Value
X-Open
Integer
Value
SQL Data Type Integer
Value
X-Open
Integer
Value
CHAR 0 1 MONEY 8
SMALLINT 1 4 DATETIME 10
INTEGER 2 5 BYTE 11
FLOAT 3 6 TEXT 12
SMALLFLOAT 4 VARCHAR 13
DECIMAL 5 3 INTERVAL 14
SERIAL 6 NCHAR 15
DATE 7 NVARCHAR 16

The following table lists integer values that represent additional data types available with Dynamic Server.

SQL Data Type Integer
Value
SQL Data Type Integer
Value
INT8 17 COLLECTION 23
SERIAL8 18 Varying-length OPAQUE type 40
SET 19 Fixed-length OPAQUE type 41
MULTISET 20 LVARCHAR (client-side only) 43
LIST 21 BOOLEAN 45
ROW 22

The same TYPE constants can also appear in the syscolumns.coltype column in the system catalog; see IBM Informix Guide to SQL: Reference.

For code that is easier to maintain, use the predefined constants for these SQL data types instead of their actual integer values. These constants are defined in the $INFORMIX/incl/public/sqltypes.h header file. You cannot, however, use the actual constant name in the SET DESCRIPTOR statement. Instead, assign the constant to an integer host variable and specify the host variable in the SET DESCRIPTOR statement file.

The following example shows how you can set the TYPE field in ESQL/C:

main()
{
EXEC SQL BEGIN DECLARE SECTION;
   int itemno, type;
EXEC SQL END DECLARE SECTION;
...
EXEC SQL allocate descriptor 'desc1' with max 5;
...
type = SQLINT; itemno = 3;
EXEC SQL set descriptor 'desc1' value :itemno type = :type;
}

This information is identical for ITYPE. Use ITYPE when you create a dynamic program that does not comply with the X/Open standard.

Compiling Without the -xopen Option

If you compile without the -xopen option, the normal Informix SQL code is assigned for TYPE. You must be careful not to mix normal and X/Open modes, because errors can result. For example, if a data type is not defined under X/Open mode, but is defined under normal mode, executing a SET DESCRIPTOR statement can result in an error.

Setting the TYPE Field in X/Open Programs

In X/Open mode, you must use the X/Open set of integer codes for the data type in the TYPE field.

If you use the ILENGTH, IDATA, or ITYPE fields in a SET DESCRIPTOR statement, a warning message appears. The warning indicates that these fields are not standard X/Open fields for a system-descriptor area.

For code that is easier to maintain, use the predefined constants for these X/Open SQL data types instead of their actual integer value. These constants are defined in the $INFORMIX/incl/public/sqlxtype.h header file.

Using DECIMAL or MONEY Data Types

If you set the TYPE field for a DECIMAL or MONEY data type, and you want to use a scale or precision other than the default values, set the SCALE and PRECISION fields. You do not need to set the LENGTHfield for a DECIMAL or MONEY item; the LENGTH field is set accordingly from the SCALE and PRECISION fields.

Using DATETIME or INTERVAL Data Types

If you set the TYPE field for a DATETIME or INTERVAL value, the DATA field can be a DATETIME or INTERVAL literal or a character string. If you use a character string, the LENGTH field must be the encoded qualifier value.

To determine the encoded qualifiers for a DATETIME or INTERVAL character string, use the datetime and interval macros in the datetime.h header file.

If you set DATA to a host variable of DATETIME or INTERVAL, you do not need to set LENGTH explicitly to the encoded qualifier integer.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]