Datatypes

The classes RWDBColumn and RWDBValue have an associated RWDBValue::ValueType that specifies the datatype of the database column or field being referenced. Mapping between this datatype and the database vendor type runs in both directions:

When fetching data or retrieving information about tables, the DB Access Module for Microsoft SQL Server converts the SQL type code provided by the Microsoft SQL Server ODBC driver into RWDBValue::ValueTypes. This mapping is shown in Table 208, which also gives the C++ datatype corresponding to the RWDBValue::ValueType.

When creating tables, the DB Access Module for Microsoft SQL Server maps the given RWDBValue::ValueType directly to the Microsoft SQL Server datatype. This mapping is shown in Table 209.

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 SourcePro API Reference.

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 Microsoft SQL Server SQL symbolic datatypes and the actual SQL datatypes used on the database, please consult Microsoft's SQL Server Library documentation.

Table 208. Datatype mapping when retrieving data

SQL Server Datatype

ODBC SQL Datatype

RWDBValue:: ValueType

C++ Datatype

char(n)
varchar(n)
text

SQL_CHAR
SQL_VARCHAR
SQL_LONGVARCHAR

String

RWCString

nchar(n)
nvarchar(n)
ntext

SQL_WCHAR
SQL_WVARCHAR
SQL_WLONGVARCHAR

UString

RWBasicUString or RWUString

binary(n)
varbinary(n)
image

SQL_BINARY
SQL_VARBINARY
SQL_LONGVARBINARY

Blob

RWDBBlob

bit

SQL_BIT

UnsignedChar

unsigned char

tinyint

SQL_TINYINT

UnsignedChar

unsigned char

smallint

SQL_SMALLINT

Short

short int

bigint

SQL_BIGINT

LongLong

long long

int

SQL_INTEGER

Int/UnsignedInt

int / unsigned int

float(p)

SQL_FLOAT

Double

double

real

SQL_REAL

Float

float

decimal(p,s)
money
smallmoney

SQL_DECIMAL

Decimal

RWDecimalPortable

timestamp

SQL_BINARY

Blob

RWDBBlob

datetime
smalldatetime1

SQL_TYPE_TIMESTAMP

DateTime

RWDateTime

Table 209. Datatype mapping when creating tables

RWDBValue:: ValueType

SQL Server Datatype

Blob

if 0 < length <= 8000 varbinary using the storageLength of the RWDBColumn, otherwise image

Char
UnsignedChar
Tiny
UnsignedTiny

tinyint

Date
DateTime

datetime

Decimal

decimal(p,s) using precision and scale of the RWDBColumn supplied, otherwise decimal(8, 0)

Duration

Not supported by Microsoft SQL Server

Float

real

Double

float

Int
UnsignedInt

smallint

LongDouble

Not supported by Microsoft SQL Server

Long
UnsignedLong

int

Short
UnsignedShort

smallint

String

if 0 < length <= 8000 bytes, varchar using the storageLength of the RWDBColumn, otherwise text

UString
MBString
WString

if 0 < length <= 4000 bytes, nvarchar using the storageLength of the RWDBColumn, otherwise ntext

LongLong
UnsignedLongLong

bigint

In this section: