My situation (Unidac for Delphi7 Version 3.70.0.17):
ProviderName = PostgreSQL (version 8.4)
TUniquery component has only one field declared:
TestField - TStringField - Size = 4
UniQuery1.Close;
UniQuery1.SQL.Clear;
UniQuery1.SQL.Add('SELECT ''Yes'' AS TestField');
UniQuery1.Open;
When I run the query the following error occurs:
---------------------------
Project1
---------------------------
UniQuery1: Type mismatch for field 'TestField', expecting: String actual: Memo.
---------------------------
OK
---------------------------
How can I fix that problem ?
Thanks!
PostgreSQL - Type mismatch (Expecting: String actual: Memo)
-
eduardomendes
- Posts: 28
- Joined: Wed 24 Feb 2010 14:08
Hello,
To resolve the problem, you should set the UnknownAsString specific option to True like:
To resolve the problem, you should set the UnknownAsString specific option to True like:
Code: Select all
UniQuery1.SpecificOptions.Values['UnknownAsString']:= 'true';-
eduardomendes
- Posts: 28
- Joined: Wed 24 Feb 2010 14:08
Hello AlexP,
my situation was resolved with SpecificOptions 'UnknownAsString', but if I run other query the following error occurs:
Config:
TUniConnection.ProviderName = PostgreSQL
TUniConnection.SpecificOptions.Values['Charset'] := 'Latin1'
TUniQuery.SpecificOptions.Values['UnknownAsString'] := 'True'
TUniQuery has one field - TPREG - TStringField - Size 5
Table:
CREATE TABLE TABLE_TEST (TPREG VARCHAR(1));
Query:
SELECT
CASE WHEN TPREG = 'Y' THEN 'YES' ELSE 'NO' END AS DsTPREG
FROM TABLE_TEST;
Error:
---------------------------
Project1
---------------------------
UniQuery1: Type mismatch for field 'DsTPREG', expecting: String actual: Memo.
---------------------------
OK
---------------------------
How can I fix that problem ?
Thanks!
my situation was resolved with SpecificOptions 'UnknownAsString', but if I run other query the following error occurs:
Config:
TUniConnection.ProviderName = PostgreSQL
TUniConnection.SpecificOptions.Values['Charset'] := 'Latin1'
TUniQuery.SpecificOptions.Values['UnknownAsString'] := 'True'
TUniQuery has one field - TPREG - TStringField - Size 5
Table:
CREATE TABLE TABLE_TEST (TPREG VARCHAR(1));
Query:
SELECT
CASE WHEN TPREG = 'Y' THEN 'YES' ELSE 'NO' END AS DsTPREG
FROM TABLE_TEST;
Error:
---------------------------
Project1
---------------------------
UniQuery1: Type mismatch for field 'DsTPREG', expecting: String actual: Memo.
---------------------------
OK
---------------------------
How can I fix that problem ?
Thanks!
Hello,
This problem is connected with the fact that PostgreSQL returns the type of this field as SQL_TEXT instead of SQL_VARCHAR, so it is the dtMemo type.
To resolve the problem you can use the following workaround:
convert data type directly like
SELECT cast(
CASE WHEN TPREG = 'Y' THEN 'YES' ELSE 'NO' END as character(5)) AS DsTPREG
FROM TABLE_TEST;
This problem is connected with the fact that PostgreSQL returns the type of this field as SQL_TEXT instead of SQL_VARCHAR, so it is the dtMemo type.
To resolve the problem you can use the following workaround:
convert data type directly like
SELECT cast(
CASE WHEN TPREG = 'Y' THEN 'YES' ELSE 'NO' END as character(5)) AS DsTPREG
FROM TABLE_TEST;