Data fetched from a database into a DBTools.h++ application may be stored internally by DBTools.h++ in instances of the RWDBValue class. Most applications can ignore RWDBValue and fetch data directly into C++ variables. If you do need to use it, Table 1 shows how Informix datatypes are mapped into RWDBValues, and lists the C++ class or datatype appropriate for each Informix datatype.
Informix Datatype | RWDBValue::ValueType | C++ Datatype |
BOOLEAN |
UnsignedChar |
unsigned char |
BYTE |
Blob |
RWDBBlob |
CHAR(n) |
String |
RWCString |
DATE |
Date |
RWDate |
DATETIME |
DateTime |
RWDBDateTime |
DECIMAL(p,s) |
Decimal |
RWDecimalPortable |
DOUBLE PRECISION |
Double |
double |
FLOAT |
Double |
double |
INTEGER |
Long |
long int |
INTERVAL |
Duration |
RWDBDuration |
MONEY(p,s) |
Decimal |
RWDecimalPortable |
NUMERIC(p,s) |
Decimal |
RWDecimalPortable |
SERIAL |
Long |
long int |
SMALLFLOAT |
Float |
float |
SMALLINT |
Short |
short int |
TEXT |
String |
RWCString |
VARCHAR |
String |
RWCString |
When an application uses the DBTools.h++ Informix Access Library to create a table, RWDBValue::ValueTypes are used to define the table's schema. These RWDBValue::ValueTypes must be mapped to a type name specific to the Informix server. Here is how that is done.
First, an Informix ODBC Driver SQL type associated with RWDBValue::ValueType must be found. Table 2 shows how DBTools.h++ chooses an SQL type to associate with a particular RWDBValue::ValueType:
RWDBValue::ValueType | Informix ODBC Driver SQL Datatypes |
Blob |
If length>255 or length = 0, SQL_LONGVARBINARY; otherwise, SQL_VARBINARY |
Char, UnsignedChar |
SQL_TINYINT |
Date |
SQL_TYPE_DATE |
DateTime |
SQL_TYPE_TIMESTAMP |
Decimal |
SQL_DECIMAL |
Double |
SQL_DOUBLE |
Duration |
SQL_INTERVAL_SECOND |
Float |
SQL_REAL |
Int, UnsignedInt |
SQL_SMALLINT |
Long, UnsignedLong |
SQL_INTEGER |
Short, UnsignedShort |
SQL_SMALLINT |
String |
If length is > 254 or length = 0, SQL_LONGVARCHAR; otherwise, SQL_VARCHAR |
In Table 2, the column on the right holds an Informix ODBC Driver SQL type to associate with an RWDBValue::ValueType.
After the type is selected, the Informix ODBC Driver function SQLGetTypeInfo() is used to find the type name associated with the chosen SQL type. The type name is then used by the DBTools.h++ Informix Access Library to create tables.
Neither DBTools.h++ nor the ODBC specification impose restrictions on the use of most datatypes. Check for specific restrictions in the documentation provided with your Informix ODBC Driver. Table 3 outlines the known restrictions associated with each DBTools.h++ type.
RWDBValue::ValueType | Restrictions |
Blob |
If the underlying datatype of the blob is CHAR, the blob cannot contain null(0) bytes. Typically, blobs can be used in all expressions; however, if the underlying datatype of the blob is BYTE, the Informix server imposes restrictions on use. See the Informix Guide to SQL, Reference. |
Char, UnsignedChar |
No restrictions. |
Date |
No restrictions. |
DateTime |
No restrictions. |
Decimal |
No restrictions. |
Double |
No restrictions. |
Duration |
No restrictions. |
Float |
No restrictions. |
Int, UnsignedInt |
No restrictions. |
Long, UnsignedLong |
No restrictions. |
MBString |
This datatype is not supported. |
String |
Typically strings can be used in all expressions; however, if the underlying datatype of the string is TEXT, the Informix server imposes restrictions on use. See the Informix Guide to SQL, Reference. |
Short, UnsignedShort |
No restrictions. |
WString |
This datatype is not supported. |
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.