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 Sybase converts the Sybase-specific datatype information provided by the database into RWDBValue::ValueTypes. This mapping is shown in Table 1, which also gives the C++ datatype corresponding to the RWDBValue::ValueType.

When creating tables, the DB Access Module for Sybase maps the given RWDBValue::ValueType into a Sybase-specific type. This mapping is shown in Table 252.

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.

.

Table 251. Datatype mapping when retrieving data

Adaptive Server Datatypes

RWDBValue::ValueType

C++ Datatype

char(n)
varchar(n)
text

String

RWCString

nchar(n)
nvarchar(n)

MBString1

RWDBMBString 1

unichar(n), univarchar(n)
unitext

UString

RWBasicUString or RWUString
RWUString

binary(n)
varbinary(n)
image
timestamp

Blob

RWDBBlob

bit
tinyint
smallint

Short

short int

int

Long

long int

decimal(p,0) p <= 9
numeric(p,0) p <= 9

Long

long int

decimal(p,0) 10 <= p < 19
numeric(p,0) 10 <= p < 19

LongLong

long long

decimal(p,0) p >= 19
numeric(p,0) p >= 19

Decimal

RWDecimalPortable

decimal(p,s)
numeric(p,s)

Decimal

RWDecimalPortable

float(p)
double precision

Double

double

real

Float

float

money
smallmoney

Decimal

RWDecimalPortable

datetime
smalldatetime2

DateTime

RWDateTime

 

Table 252. Datatype mapping when creating tables

RWDBValue::ValueType

Adaptive Server Datatype

Char
UnsignedChar
Tiny
UnsignedTiny

tinyint

String

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

WString
MBString

if 0 < length <= 255, nvarchar using the storageLength of the RWDBColumn, otherwise text

UString

univarchar, using the storageLength of the RWDBColumn

Blob

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

Short
UnsignedShort

smallint

Int
UnsignedInt

int

Long
UnsignedLong

int

Float

real

Double

float(p), using precision of column

Decimal

money or decimal(p,s) using precision and scale of column. See below.

Date
DateTime

datetime

Duration

Not supported by the Sybase client

In this section: