Handling of varchar/char - Fields

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

Post Reply
belvasis
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 13.11.2006, 08:17

Handling of varchar/char - Fields

Post by belvasis »

Hi,

i have a simple question:

I have a varchar or char field and the data only contains blanks:
STR_FIELD = ' '
If i use pQuery.FieldByName('STR_FIELD').AsString the result is
an empty string ''. That means, the blank will be completly ignored.
If i change the type of the field to text, the FieldByName - call gives me the correct result.
So what can i do? I can not change the fieldtype in the hole database from varchar to text but i urgently need the information about the blank!
Are there any ideas or fixes for this problem?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

What database are you using? If the field is varchar, it's normal that trailing (=all here) spaces are removed from the string by the database. (At least for oracle and mysql, as far as I know.) For a Char, this is not true, so maybe we should do the test ourselves. I move this post to the bug reports forum. (Our todo list for bugs) Please keep an eye on it...

Mark
belvasis
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 13.11.2006, 08:17

Post by belvasis »

I use MSSQL 2000/2005. If i do the query using the EnterpriseManager the spaces are still part of the Resultset, so i don't think the SQLServer removes the spaces from the database. If i use ODBC i'm also able to test for the blanks. But moving to ODBC is not an option...
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

I checked this for mysql. There everything seems OK. Strange enough the spaces are stripped away for char and not for varchar and text types. But that is the same when I check it with the mysql commandline tool.

So somebody using MSSQL will have to look at it.

Mark
Nico Oosthuizen
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 08.01.2007, 11:22
Location: Centurion, South Africa

Post by Nico Oosthuizen »

Hi

I'm looking at using Zeos instead of dbexpress in Delphi and Kylix. I'm impressed so far. Keep up the good work.

Using:
Under Windows:
Windows 98se
Delphi 7
MySql 5.0 & 4.0

Under Linux:
Mandriva 2006.0
Kylix 3
MySql 4.1

My problem:

In a dbgrid box I can view all the records in my db when I use dbexpress.

With Zeos the char & varchar fields shown in the dbgrid but they are just blank. The date, int and float fields are all displayed correctly.

When I copy the exact same program from the Windows machine to the Linux machine and compile it under Kylix all the fields are displayed.
In the program I use as my hostname 192.168.3.1. This is the Windows machine address. When I connect from the Linux machine it is therefore reading the information from the same db.

I have tried with mysql, mysql-4.1, mysql-5 protocols. Same result.
Tried with MySql 4 and MySql 5 servers with the same result.

Nico
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi Nico,

I never had this kind of trouble in this configuration. Not using Win98, however. Do you have a very stupid example project that shows the problem? Just 1 connection, zquery, datasource and grid? Database name : zeoslib or test. Please provide a small dataset loading script with create table command. (eg by taking a backup)

Can you also tell which version of zeoslib you are using?

Mark
BTW : can you please register to the bug tracker instead of hijacking this thread? So we can finally get rid of this forum in a reasonable time.
Post Reply