The classes RWDBColumn and RWDBValue have an associated RWDBValue::ValueType that specifies the data type of the database column or field being referenced. Mapping between this data type and the database vendor type runs in both directions:
When fetching data or retrieving information about tables, the DB Access Module for Sybase CT converts the Sybase-specific data type information provided by the database into RWDBValue::ValueTypes. This mapping is shown in Table 1, which also gives the C++ data type corresponding to the RWDBValue::ValueType.
When creating tables, the DB Access Module for Sybase CT maps the given RWDBValue::ValueType into a Sybase-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 DB Interface Module Reference Guide.
.
Adaptive Server Data Type | RWDBValue::ValueType | C++ Data Type |
char(n) | String | |
nchar(n) | MBString1 | |
unichar(n) univarchar(n) | UString | |
binary(n), | Blob | |
bit | 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 | |
decimal(p,s) numeric(p,s) | Decimal | |
float(p) | Double | double |
real | Float | float |
money | Decimal | |
datetime | DateTime |
RWDBValue::ValueType | Adaptive Server Data Type |
Char UnsignedChar | tinyint |
String | if 0 < length <= 255, varchar using the storageLength of the RWDBColumn, otherwise text |
WString | if 0 < length is <= 255, nvarchar using the storageLength of the RWDBColumn, otherwise text |
UString1 | univarchar, using the storageLength of the RWDBColumn |
Blob | if 0 < length <= 255, varbinary using the storageLength of the RWDBColumn, otherwise image |
Short | smallint |
Int | int |
Long | 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 |
Duration | Not supported by Client-Library |
Sybase Client-Library and servers place restrictions on the use of certain data types. Where possible, the DB Interface Module is flexible about data types. 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 data types can be used. Table 3 outlines the restrictions associated with each DB Interface Module type.
RWDBValue::ValueType | Restrictions |
Char | No restrictions. |
String | Not supported on RWDBBoundExpr if string size is bigger than 16384 bytes. |
Blob | Not supported on RWDBBoundExpr. |
Short | No restrictions. |
Int | No restrictions. |
Long | No restrictions. |
Double | No restrictions. |
Float | No restrictions. |
Decimal | The precision and scale of a value can vary depending on the version of Client-Library 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 Client-Library |
LongLong, UnsignedLongLong | Table creation not supported. |
LongDouble | No restrictions. |
Sybase Adaptive Servers support identity columns. Identity columns can be used within the DB Interface Module, subject to the restrictions specified by the Sybase documentation. For more information, see the Transact-SQL User's Guide.
Applications can create tables with identity columns by providing the native SQL statement, and execute it using RWDBConnection::executeSql().
Applications can also acquire the schema of a table that contains an identity column. The schema will return identity columns as RWDBValue::Decimal data types, however there is no way to determine if the column is actually an identity column. Applications must know the identity column of a table to use it correctly.
New rows can be inserted into tables by not providing values for identity columns, effectively allowing the server to provide values. Values for identity columns should only be provided if an application demands a specific value, however. All values must follow the restrictions of the server.
Of course, updating identity columns is strictly forbidden by Adaptive Server.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.