Recent

Author Topic: DBgrid  (Read 5953 times)

cpalx

  • Hero Member
  • *****
  • Posts: 753
DBgrid
« 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

audio2

  • Newbie
  • Posts: 5
Re: DBgrid
« Reply #1 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

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: DBgrid
« Reply #2 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
Re: DBgrid
« Reply #3 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)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: DBgrid
« Reply #4 on: June 18, 2009, 05:17:39 am »
thanks, i solved it

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

thanks a lot.

tatamata

  • Hero Member
  • *****
  • Posts: 787
    • ZMSQL - SQL enhanced in-memory database
Re: DBgrid
« Reply #5 on: June 18, 2009, 11:46:24 am »
Yes,
Use only Varchar for strings in PostgreSQL.

 

TinyPortal © 2005-2018