Zeos does not recognize the command case of PostgreSQL.

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Zeos does not recognize the command case of PostgreSQL.

Postby elidorio2 » 31.10.2012, 02:08

I use a search where the case statement, to display the value of the column case, it shows the value in dbgrig. The Zeos shows the value as memo.
follows the SQL command below.

select a.cd_fil,a.cd_titulo,a.no_doc,a.no_origem,
case
when a.fg_tipo_pgto = 'DIN' then 'Dinheiro'
when a.fg_tipo_pgto = 'CAR' then 'Cartão'
when a.fg_tipo_pgto = 'CHE' then 'Cheque'
when a.fg_tipo_pgto = 'DUP' then 'Duplicata'
when a.fg_tipo_pgto = 'PRO' then 'Promiss.'
when a.fg_tipo_pgto = 'BOL' then 'Boleto'
when a.fg_tipo_pgto = 'DEP' then 'Depósito'
when a.fg_tipo_pgto = 'DDA' then 'DDA'
ELSE 'NDA'
end as .fg_tipo_pgto
,a.no_parcela,a.dt_conta,
a.dt_vcto,a.fg_paga,a.vlr_mov,a.cd_fornec,
b.de_fantasia,a.dt_pgto,a.vlr_pgto
from contapag a,forneced b
where a.cd_fornec = b.cd_fornec
order by a.dt_vcto,a.cd_titulo




--
Edson
You do not have the required permissions to view the files attached to this post.

Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 162
Joined: 18.03.2008, 13:03
Contact:

Postby Wild_Pointer » 31.10.2012, 09:46

Hello elidorio2,

the problem is the Postgresql server presumes the result of case command is text. Text type fields are used as memo fields in Zeos. Try casting the result of case command to character varying (20) and you'll get what you want.

example
SELECT ..., CAST( case when .... then .... end as varchar(20)) as fg_tipo_pgto

Good luck!

elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Postby elidorio2 » 31.10.2012, 13:18

Strange!

Running this command Pgadmin III and by and SQL Manager for PostgreSQL works normal.

Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 162
Joined: 18.03.2008, 13:03
Contact:

Postby Wild_Pointer » 31.10.2012, 14:41

Not strange at all :)

This is how Data Aware component TDbGrid works. It does not show the value for the memo fields.
Someone should correct me if I'm mistaken but it is the libpq that tells the Zeos lib that the column is memo. You could try selecting value from the column that is varchar(N) where N > 255 (300 for example). You'll notice you get memo too. And if you use pgAdmin try Select 'aaa'; You'll see the result is of type text (not char(3) as you might have expected). And text can be as long as 10^9 of Char.
So it is just the way it is. You can cast your long strings or strings of unknown length to something smaller than 255 in length, o you can change the way memofields are displayed. I prefer casting...

Good luck!


Return to “ZeosLib 7.0 Beta Forum”

Who is online

Users browsing this forum: No registered users and 1 guest