Page 1 of 1

Zeos + Postgresql + D2005

Posted: 11.05.2010, 13:03
by stepel
Hi,

i have problem with CAST expression AS type commend. I use TZQuery and i want to get TStringField fileds from column (type - text).

So i try:


SELECT
CAST (vname AS varchar(100)),CAST(vvalue AS varchar(100)), id
FROM schemat.baza WHERE vname ~* :var_name ORDER BY vname,id

and i get :
vname - TStringField
vvalue - TMemoField
id - TIntegerField

why vvalue isn't TStringField?

When i use:

SELECT
id,CAST (vname AS varchar(100)),CAST(vvalue AS varchar(100))
FROM schemat.baza WHERE vname ~* :var_name ORDER BY vname,id

where id is on the first place i get :

id - TIntegerField
vname - TMemoField
vvalue - TMemoField

Any ideas?

Posted: 11.05.2010, 22:20
by seawolf
Can you provide the table declaration?

Posted: 11.05.2010, 22:44
by stepel
we don't need it ;) i solved that problem.

in table declaration is:
(
id serial NOT NULL,
vname text,
vvalue text,
CONSTRAINT pk_eknr_cfg PRIMARY KEY (id)
)

but the solution is:

SELECT
CAST (vname AS varchar(100)) AS vname,CAST(vvalue AS varchar(100)) AS vvalue, id
FROM schemat.baza WHERE vname ~* :var_name ORDER BY vname,id

In BDE it wasn't problem when i used CAST without new column name. But in that situation (zeos) it seems to be important.

Posted: 13.05.2010, 00:40
by mdaems
It may be because the parser has a problem with the 'AS' within the Cast expression that's solved by adding the second AS before the alias name.

Mark

Posted: 13.05.2010, 11:52
by stepel
Yes maybe, but the most important is that everything work :)