Lazarus

Programming => Databases => Topic started by: cpalx on June 17, 2009, 08:32:50 pm

Title: DBgrid
Post by: cpalx on June 17, 2009, 08:32:50 pm
Hello, i am using Lazarus 0.97 (2009-6-16) on windows XP SP3, i have Zeosbb installed to connect to PostgreSQL 8.3 version.

It is working almost perfect, but this query

select fieldone || fieldtwo as data, field2,field3 from aTable

when i use dbgrid to show, it displays (memo) instead of the real data. Others fields display ok

how can i use that query and display good in the dbgrid
Title: Re: DBgrid
Post by: audio2 on June 17, 2009, 09:32:55 pm
I had a similar problem with a sqlite database all text fields where displaying as (MEMO), it was fixed by changing the text fields to VARCHAR fields.
Then everything displayed fine.

Don't know if this applies to PostgreSQL but it worked with Sqlite

hope this helps

audio2
Title: Re: DBgrid
Post by: cpalx on June 17, 2009, 09:45:39 pm
if you refer to database field (in postgres), my fields are varchar, when i display ine by one it dispplay correctly but when i join them ( || ) then display (memo)

thanks for you replay
Title: Re: DBgrid
Post by: Marc on June 17, 2009, 11:48:30 pm
the reason is that concatinated varchars are seen as one big varchar with size (iirc) > 255.
if your fields are shorter, use a cast:

(field1 || field2)::varchar(sum_of_length_of_both_fields_or enything_else_you_like)
Title: Re: DBgrid
Post by: cpalx on June 18, 2009, 05:17:39 am
thanks, i solved it

select cast ( field1 || field2 as varchar) from table

thanks a lot.
Title: Re: DBgrid
Post by: tatamata on June 18, 2009, 11:46:24 am
Yes,
Use only Varchar for strings in PostgreSQL.
TinyPortal © 2005-2018