Page 1 of 1

ODBC Data Type Mapping

Posted: Thu 16 Apr 2020 19:50
by ptyukin
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.

Re: ODBC Data Type Mapping

Posted: Fri 17 Apr 2020 19:29
by MaximG
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;
   ...

Re: ODBC Data Type Mapping

Posted: Fri 17 Apr 2020 19:51
by ptyukin
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?

Re: ODBC Data Type Mapping

Posted: Mon 27 Apr 2020 14:07
by MaximG
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.

Re: ODBC Data Type Mapping

Posted: Mon 27 Apr 2020 14:12
by ptyukin
MaximG,

Good news. Thank you.