smallint tdblookup combo box

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

smallint tdblookup combo box

Post by albourgz » Tue 15 Nov 2016 13:24

TUniQuery

Code: Select all

SELECT ID, LIBELLE FROM LIBELLES 
WHERE Categ='TAG' OR ID=0
ORDER BY UPPER(LIBELLE)
id is number(4) in oracle, smallint in postgres.
Problem: when connected to oracle, I made Add All Fields to uniquery-> Unidac added a TFloatField .
Then I connect the app to Postgres db, and unidac claims: Actual: smallInt, expected: TFloatField .

So app works with oracle and not Postgres. Any hint?

ertank
Posts: 172
Joined: Wed 13 Jan 2016 16:00

Re: smallint tdblookup combo box

Post by ertank » Tue 15 Nov 2016 15:16

Hi,

Did you try running query *without* adding fields in TUniQuery for both Oracle and Prosgres?

I personally prefer not to add fields at design-time if not absolutely necessary.

albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Re: smallint tdblookup combo box

Post by albourgz » Tue 15 Nov 2016 15:34

I don't do it always, but there are many places in the code where this is used.
So removing this will cause a lot of rewrites!
Also, there are places where it is difficult to do it in another way e.g. to set column sequence that does not match sql statement in a TCRDBGrid, and to set column with field by field.

I would prefer something else than changing every place where this is used.

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

Re: smallint tdblookup combo box

Post by MaximG » Thu 17 Nov 2016 13:29

Please specify what parameters you use working with Oracle DB? Send us a small code snippet that demonstrates in RunTime values of used TUniConnection properties and also the DataTypeMapping parameters. Note that some specific TUniConnection properties can directly affect the needed behavior, e.g “EnableIntegers” : https://www.devart.com/unidac/docs/?oraprov_article.htm .

albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Re: smallint tdblookup combo box

Post by albourgz » Thu 17 Nov 2016 16:50

"EnableIntegers" is the issue: it has always been false in my application, so that standard sql number (x) is always mapped to a float when added using IDE to a TUniQuery connected to oracle. If connection is changed to postgres, field stays float and query cannot been opened in IDE anymore.

Problem: EnableIntegers is related to oracle specific options, not to TUniConnection. There is no EnableIntegers in postgres specific options.

Would it be feasable to set EnableIntegers as a TUniConnection option in the next update, so that the Float field work with all databases?

Kind Regards

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

Re: smallint tdblookup combo box

Post by MaximG » Tue 22 Nov 2016 08:52

You are absolutely right — the “EnableIntegers” option is specific when using OracleUniProvider. Therefore, it is listed in UniConnection.SpecificOptions when working with Oracle DB. Please explain how the presence of this option can affect work with PostgreSQLUniProvider?
Please note that the “EnableIntegers” option is deprecated. Currently, UniDAC components allow to implement full functionality that interests you with the help of DataTypeMapping : https://www.devart.com/unidac/docs/?dat ... apping.htm

albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Re: smallint tdblookup combo box

Post by albourgz » Tue 22 Nov 2016 09:04

The problem is that at design-time, the field is created and defined according to one database.
The same app works with different databases around the world. In some databases, it is Number(9), in others it is number(12) ... but I would like to use the same executable and it does not work, as some need largeint and others int.
So I would like largeint or float to be used always so that the number size in the database is not an issue.

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

Re: smallint tdblookup combo box

Post by MaximG » Wed 23 Nov 2016 13:40

Exactly for implementation of your described behavior, we have DataTypeMapping in UniDac: https://www.devart.com/unidac/docs/?dat ... apping.htm .
You can flexibly customize data types mapping between the DB data types and Delphi field types.
For example, all the fields of the NUMERIC(9, 0) type in PostgreSQL can be represented as integers :

Code: Select all

   UniConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 0, 9, 0, 0, ftInteger); 
and the fields of the NUMERIC(12, 0) type as strings :

Code: Select all

   UniConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 0, 12, 0, 0, ftString); 

Post Reply