Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Access Module for ODBC User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.3 Data Types

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:

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.

Table 1: Type mapping when retrieving data

ODBC Data Type RWDBValue::ValueType C++ Data Type

SQL_NUMERIC
SQL_DECIMAL

Decimal

RWDecimalPortable

SQL_BINARY
SQL_VARBINARY
SQL_LONGVARBINARY

Blob

RWDBBlob

SQL_BIT

UnsignedChar

unsigned char

SQL_DOUBLE
SQL_FLOAT

Double

double

SQL_INTEGER

Long/UnsignedLong

long int/unsigned long int

SQL_INTERVAL

Duration

RWDBDuration

SQL_LONGVARCHAR
SQL_VARCHAR
SQL_CHAR

String

RWCString

SQL_REAL

Float

float

SQL_SMALLINT

Short/UnsignedShort

short int/unsigned short int

SQL_TYPE_DATE

Date

RWDate

SQL_TYPE_TIME

SQL_TYPE_TIMESTAMP

DateTime

RWDBDateTime1 RWDateTime

SQL_WLONGVARCHAR
SQL_WVARCHAR
SQL_WCHAR

WString

RWWString

SQL_BIGINT

LongLong/UnsignedLongLong

long long/unsigned long long

  1. RWDBDateTime is deprecated. Please use RWDateTime.

Table 2: Type mapping when creating tables 

RWDBValue::ValueType Possible ODBC Data Types: the type chosen is the first type supported by the underlying driver

Blob

If 0 < length <= 255, {SQL_VARBINARY, SQL_BINARY, SQL_LONGVARBINARY, SQL_LONGVARCHAR} using the storageLength of the RWDBColumn if applicable; otherwise, {SQL_LONGVARBINARY,SQL_VARBINARY,

SQL_BINARY, SQL_LONGVARCHAR} using the storageLength of the RWDBColumn if applicable

Char, UnsignedChar

{SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER,
SQL_DECIMAL, SQL_NUMERIC}

Date

{SQL_TYPE_DATE, SQL_TYPE_TIMESTAMP}

DateTime

{SQL_TYPE_TIMESTAMP, SQL_TYPE_DATE}

Decimal

{SQL_DECIMAL, SQL_NUMERIC, SQL_DOUBLE}, using the precision and scale of the RWDBColumn if applicable

Double

{SQL_DOUBLE, SQL_FLOAT, SQL_DECIMAL, SQL_NUMERIC }

Duration

{SQL_INTERVAL_SECOND}

Float

{SQL_REAL, SQL_DOUBLE, SQL_FLOAT, SQL_DECIMAL, SQL_NUMERIC} using the precision and scale of the RWDBColumn if applicable

Int, UnsignedInt

{SQL_SMALLINT, SQL_INTEGER, SQL_REAL,
SQL_DOUBLE, SQL_FLOAT, SQL_DECIMAL, SQL_NUMERIC}

Long, UnsignedLong

{SQL_INTEGER, SQL_REAL, SQL_DOUBLE,
SQL_FLOAT, SQL_DECIMAL, SQL_NUMERIC}

LongLong, UnsignedLongLong

{SQL_BIGINT, SQL_DECIMAL1, SQL_REAL}

Short, UnsignedShort

{SQL_SMALLINT, SQL_INTEGER, SQL_REAL,
SQL_DOUBLE, SQL_FLOAT, SQL_DECIMAL, SQL_NUMERIC}

String

If 0 < length <= 255,

{SQL_VARCHAR, SQL_CHAR, SQL_LONGVARCHAR}; otherwise, {SQL_LONGVARCHAR, SQL_VARCHAR, SQL_CHAR} using the storageLength of the RWDBColumn, if applicable.

WString

If 0 < length <= 254, {SQL_WVARCHAR, SQL_WCHAR, SQL_WLONGVARCHAR} using the storageLength of the RWDBColumn if applicable; otherwise, {SQL_WLONGVARCHAR,

SQL_WVARCHAR, SQL_WCHAR} using the storageLength of the RWDBColumn if applicable.

  1. The precision of the decimal type created is 20.

2.3.1 Restrictions on the Use of Data Types

Neither the DB Interface Module nor the ODBC specification impose restrictions on the use of most data types, but individual ODBC drivers may. Check for specific restrictions in the documentation provided with your ODBC driver. Table 3 outlines the known restrictions associated with each DB Interface Module type.

Table 3: Restrictions on the use of DB Interface Module data types 

RWDBValue::ValueType Restrictions

Blob

No restrictions.

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.

LongLong, UnsignedLongLong

No restrictions.

MBString

This data type is not supported.

String

No restrictions.

Short, UnsignedShort

No restrictions.

WString

This data type may not be supported -- check your driver documentation.

UString

This data type is not supported.

LongDouble

For input binding, long double value inserted should be in range of what database supports. Please check your database documentation for details.



Previous fileTop of DocumentContentsIndex pageNext file

© 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.