ODBC Data Type Mapping

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ptyukin
Posts: 6
Joined: Thu 16 Apr 2020 18:58

ODBC Data Type Mapping

Post by ptyukin » Thu 16 Apr 2020 19:50

Hello DevArt,

I would like to migrate legacy app to UniDAC with ODBC provider. I have couple of questions.

Is there any ODBC Data Mapping documentation? What is the default mapping?
Can I map ODBC SQL_TYPE_TIMESTAMP = 93 data type to string field when using TUniQuery for example?

Maybe there is some unit with ODBC constants like UniDAC has for Oracle Data Types?
---
UniConnection.DataTypeMap.Clear;
UniConnection.DataTypeMap.AddDBTypeRule(oraVarchar2, ftString);
UniConnection.DataTypeMap.AddDBTypeRule(oraNVarchar2, ftWideString);
---

Thank you.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: ODBC Data Type Mapping

Post by MaximG » Fri 17 Apr 2020 19:29

DataTypeMapping is available when working with ODBCUniProvider. The following code sample illustrates the use of DataTypeMapping:

Code: Select all

   uses ODBCDataTypeMapUni;
   ...
   UniQuery.DataTypeMap.AddDBTypeRule(odbcTimeStamp, ftString);
   UniQuery.Open;
   ...

ptyukin
Posts: 6
Joined: Thu 16 Apr 2020 18:58

Re: ODBC Data Type Mapping

Post by ptyukin » Fri 17 Apr 2020 19:51

MaximG,

Thank you for the example.
Can you give a complete list of ODBC data type constants with their values? The UniDAC version we currently use, unfortunately, is without source code and documentation doesn't contain this info.
Can you also clarify the default mapping of data types?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: ODBC Data Type Mapping

Post by MaximG » Mon 27 Apr 2020 14:07

When working with DataTypeMap using ODBCUniProvider, you can use the following ODBC types:

odbcChar
odbcWideChar
odbcVarChar
odbcWideVarChar
odbcLongVarChar
odbcWideLongVarChar
odbcSmallInt
odbcTinyInt
odbcInteger
odbcBigInt
odbcDecimal
odbcFloat
odbcDouble
odbcReal
odbcNumeric
odbcDate
odbcTime
odbcTimeStamp
odbcBit
odbcBinary
odbcVarBinary
odbcLongVarBinary
odbcBlob
odbcClob
odbcXml
odbcVariant
odbcUTinyInt
odbcUSmallInt
odbcUInteger
odbcUBigInt

We'll add the needed description to our product's documentation.

ptyukin
Posts: 6
Joined: Thu 16 Apr 2020 18:58

Re: ODBC Data Type Mapping

Post by ptyukin » Mon 27 Apr 2020 14:12

MaximG,

Good news. Thank you.

Post Reply