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 Oracle OCI converts the Oracle-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 Oracle OCI maps the given RWDBValue::ValueType into an Oracle-specific 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 SourcePro API Reference.

Table 231. Type mapping when retrieving data

Oracle Datatype

RWDBValue::ValueType

C++ Datatype

CHAR(n)
VARCHAR2(n)

String

RWCString

NCHAR(n)
NVARCHAR2(n)

UString

RWBasicUString
or RWUString

LONG

String

RWCString

CLOB

String

RWCString

RAW(n)
LONG RAW

Blob

RWDBBlob

BLOB

Blob

RWDBBlob

NUMBER(p,0) 0 < p < 10¹

Long

long int

NUMBER(p,0) 10 <= p < 19¹

LongLong

long long

NUMBER(p,0) p >= 19

Decimal

RWDecimalPortable

NUMBER(p,s) 0 < p < 10¹

Double

double

NUMBER(p,s) p >= 10

Decimal

RWDecimalPortable

NUMBER

Decimal

RWDecimalPortable

FLOAT(p)

Double

double

BINARY_FLOAT

Float

float

BINARY_DOUBLE

Double

double

DATE²

DateTime

RWDateTime

ROWID

String

RWCString

MLSLABEL

String

RWCString

TIMESTAMP² ³

DateTime

RWDateTime

 

Table 232. Type mapping when creating tables

RWDBValue::ValueType

Oracle Datatype

Blob

BLOB, if nativeType of the RWDBColumn is SQLT_BLOB
RAW(n), using the storageLength of the RWDBColumn for value n, if 0 < storageLength <= 2000
LONG RAW otherwise

Char
UnsignedChar

NUMBER(d), where d is the number of digits needed to store the maximum value a char can express on the client machine

Date

DATE

DateTime

DATE if useTimestamp() is false
TIMESTAMP(p), using precision of RWDBColumn, if useTimestamp() is true and precision is specified
TIMESTAMP otherwise

Decimal

NUMBER(p,s), using precision and scale of RWDBColumn if precision is specified
NUMBER otherwise

Double

FLOAT(126)

Duration

Not supported by DB Access Module for Oracle OCI.

Float

FLOAT(p) using precision of RWDBColumn, if specified.
FLOAT otherwise

Int
UnsignedInt

NUMBER(d), where d is the number of digits needed to store the maximum value an int can express on the client machine

Long
UnsignedLong

NUMBER(d), where d is the number of digits needed to store the maximum value a long can express on the client machine

LongLong
UnsignedLongLong

NUMBER(d) where d is the number of digits needed to store the maximum value a long long can express on the client machine

MBString
UString
WString

NVARCHAR2(n) using the storageLength of the RWDBColumn, if specified
NVARCHAR2(2000) otherwise

Short
UnsignedShort
Tiny
UnsignedTiny

NUMBER(d), where d is the number of digits needed to store the maximum value a short can express on the client machine

String

CLOB, if nativeType of the RWDBColumn is SQLT_CLOB
VARCHAR2(n), using the storageLength of the RWDBColumn, if 0 < storageLength <= 4000
LONG otherwise

NoType

If nativeType of the RWDBColumn is:
SQLT_NUM, then NUMBER(p,s), using precision and scale of the RWDBColumn
SQLT_RDD, then ROWID
SQLT_BFLOAT or SQLT_IBFLOAT, then BINARY_FLOAT
SQLT_BDOUBLE or SQLT_IBDOUBLE, then BINARY_DOUBLE

In this section: