The classes RWDBColumn and RWDBValue have an associated RWDBValue::ValueType that specifies the data type of the database column or field being referenced. Mapping between this data type and the database vendor type runs in both directions:
When fetching data or retrieving information about tables, the DB Access Module for DB2 CLI converts the SQL datatype provided by DB2's ODBC implementation into RWDBValue::ValueTypes. This mapping is shown in Table 1, which also gives the C++ data type corresponding to the RWDBValue::ValueType.
When creating tables, the DB Access Module for DB2 CLI maps the given RWDBValue::ValueType to a DB2 server type. This mapping is shown in Table 2.
The RWDBValue::ValueTypes, accessible through the type() method, are uniform across all Access Modules. For a complete explanation of the DB Interface Module data model, see Chapter 7, "The Data Model," in the DB Interface Module User's Guide and RWDBValue in the DB Interface Module Reference Guide.
NOTE -- We update the mapping tables regularly, but Rogue Wave cannot be responsible for changes made by other vendors. For the latest information on mappings between the DB2 SQL data types and the actual DB2 server types used on the database, please consult IBM's DB2 Call Level Interface Guide and Reference.
DB2 Data Type | DB2 SQL Data Type1 | RWDBValue:: ValueType | C++ Data Type |
CHAR | SQL_CHAR | String or UString | |
CHAR FOR BIT DATA | SQL_BINARY | Blob | |
SMALLINT | SQL_SMALLINT | Short | short int |
BIGINT | SQL_BIGINT | LongLong | long long |
INTEGER | SQL_INTEGER | Long | long int |
DOUBLE FLOAT | SQL_DOUBLE SQL_FLOAT | Double | double |
REAL | SQL_REAL | Float | float |
DATE | SQL_TYPE_DATE | Date | |
NUMERIC | SQL_NUMERIC | Decimal | |
TIMESTAMP | SQL_TYPE_TIMESTAMP | DateTime | RWDBDateTime3 and RWDateTime |
GRAPHIC4 | SQL_GRAPHIC SQL_WCHAR SQL_WVARCHAR SQL_WLONGVARCHAR | WString |
RWDBValue:: ValueType | DB2 Data Type |
Char | SMALLINT |
String UString | If 0 < length < 255, VARCHAR using the storageLength of the RWDBColumn If length > 32700, CLOB using the storageLength of the RWDBColumn, else LONG VARCHAR |
WString | Not supported |
Blob | If 0 < length < 255 VARCHAR FOR BIT DATA using the storageLength of the RWDBColumn If length > 32700, BLOB using the storageLength of the RWDBColumn else LONG VARCHAR FOR BIT DATA |
Short | SMALLINT |
Int | INTEGER |
Long | INTEGER |
LongLong | BIGINT |
Float | FLOAT |
Double | DOUBLE |
LongDouble | Not supported |
Decimal | DECIMAL using the precision and scale of the RWDBColumn, if supplied |
Date | DATE |
DateTime | TIMESTAMP |
Duration | Not supported |
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.