Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Access Module for Sybase User's Guide

2.3 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:

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 C++ API Reference Guide.

.

Table 1: Datatype mapping when retrieving data

Adaptive Server Datatypes RWDBValue::ValueType C++ Datatype
char(n)
varchar(n)
text
String RWCString
nchar(n)
nvarchar(n)
MBString1 RWDBMBString1
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 RWDBDateTime3
RWDateTime
  1. The Sybase Adaptive Server usertype value, when available, is used to differentiate standard and national character strings. See Section 2.11 on internationalization.
  2. Values of type datetime and smalldatetime are affected by the time zone setting on either RWDBDatabase or RWDBConnection while sending and retrieving data. The time zone setting can be set programmatically with the timeZone() method in each of these classes.
  3. RWDBDateTime is now deprecated. Please use RWDateTime.

Table 2: 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

2.3.1 Restrictions on the Use of Datatypes

Sybase Open Client Client-Library and Sybase Adaptive Server Enterprise place restrictions on the use of certain datatypes. Where possible, the DB Interface Module is flexible about datatypes. However, there are some situations where conversions are not possible, and in these cases your application must be aware of the contexts in which certain datatypes can be used. Table 3 outlines the restrictions associated with each DB Interface Module type.

Table 3: Restrictions on the use of DB Interface Module datatypes

RWDBValue::ValueType Restrictions
Char
UnsignedChar
No restrictions.
String
WString
MBString
UString
Not supported on RWDBBoundExpr if string size is bigger than 16384 bytes.
Blob Not supported on RWDBBoundExpr.
Short
UnsignedShort
No restrictions.
Int
UnsignedInt
No restrictions.
Long
UnsignedLong
No restrictions.
Double No restrictions.
Float No restrictions.
Decimal The precision and scale of a value can vary depending on the version of the Sybase client and server. Consistent versions of clients and servers can eliminate difficulties in conversions.
Date No restrictions.
DateTime Accuracy limited to 3.33 milliseconds by Sybase.
Duration Not supported by the Sybase client
LongLong
UnsignedLongLong
Table creation not supported.
LongDouble No restrictions.


Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.