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 PostgreSQL converts the PostgreSQL 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 PostgreSQL maps the given RWDBValue::ValueType into a PostgreSQL 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 233. Type mapping when retrieving data

PostgreSQL Datatype

RWDBValue:: ValueType

C++ Datatype

bigint

LongLong

long long

bigserial

LongLong

long long

bit
bit varying(n)

String

RWCString

boolean

String

RWCString

box

String

RWCString

bytea

Blob

RWDBBlob

char(n)

String

RWCString

varchar(n)

String

RWCString

cidr

String

RWCString

circle

String

RWCString

date

Date

RWDate

double precision

Double

double

inet

String

RWCString

integer

Long

long int

interval(p)

Duration

RWDBDuration

line

String

RWCString

lseg

String

RWCString

macaddr

String

RWCString

money

String

RWCString

numeric

Decimal

RWDecimalPortable

path

String

RWCString

point

String

RWCString

polygon

String

RWCString

real

Float

float

smallint

Short

short int

serial

Long

long int

text

String

RWCString

time(p)¹

DateTime

RWDateTime

time(p) with
time zone¹

DateTime

RWDateTime

timestamp(p)¹

DateTime

RWDateTime

timestamp(p)
with time zone¹

DateTime

RWDateTime

Table 234. Type mapping when creating tables

RWDBValue::ValueType

PostgreSQL Datatype

Blob

bytea

Char
UnsignedChar
Tiny
UnsignedTiny
Short
UnsignedShort

smallint

Date

date

DateTime

timestamp[(p)] using precision of column if specified

Decimal

numeric(p,s) using precision and scale of column if specified

Duration

interval[(p)] using precision of column if specified

Double

double precision

Float

real

Int
UnsignedInt

integer

Long
UnsignedLong

integer

LongLong
UnsignedLongLong

bigint

String

varchar(n) if storageLength is specified, else text

 

In this section: