tdblookupcombobox widememo in postgres

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

tdblookupcombobox widememo in postgres

Post by albourgz » Mon 14 Nov 2016 18:24

Hi,

using unidac 6.4.15 /c++ builder XE10 / VCL win32.

I have a form having a tuniquery, tunidataset and tdblookup comboxbox.
Query is this one:

Code: Select all

SELECT * FROM
   (SELECT IDItem AS ID, groupName AS NAME FROM groupItems WHERE groupDefId=3
    UNION 
    SELECT 0, 'GENERIQUE' ) xxx1
ORDER BY UPPER(Name)
Combo's KeyField is ID, ListField is Name.
If backend is Oracle, field is displayed correctly in combo.
If backend is Postgres, comboxbox displays all lines with value (WIDEMEMO) .

Any hint to make it work the same with both databases? Why does it work in Oracle and not in Postgres?

Regards,
Alain

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: tdblookupcombobox widememo in postgres

Post by azyk » Tue 15 Nov 2016 11:17

For the specified SQL query with UNION PostgreSQL does not return the length for the NAME alias, therefore UniDAC maps it as a Memo type.

To solve the issue, you can explicitly specify a data type for the NAME alias in the 2nd SELECT section of SQL query. For example, if the groupName field in the groupItems table has a type character varying(20), then SQL query will look like this:

Code: Select all

SELECT * FROM 
(SELECT IDItem AS ID, groupName AS NAME FROM groupItems WHERE groupDefId=3
UNION 
SELECT 0, 'GENERIQUE'::character varying(20) ) xxx1
ORDER BY UPPER(Name) 
As another issue solution you can use Data Type Mapping. For example, before opening dataset add such a rule of mapping for the NAME field:

Code: Select all

UniQuery1.DataTypeMap.AddFieldNameRule('NAME', ftWideString);
More details about Data Type Mapping you can read in our online documentation: https://www.devart.com/unidac/docs/inde ... apping.htm

Post Reply