Field of query result returns 0

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
christophe-marelec
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 27.03.2008, 10:46

Field of query result returns 0

Post by christophe-marelec »

Hi to all,

I am using Borland C++ Builder 5, MySQL 4.1.14 and Zeos components 6.6.2.

When I execute the following query:

SELECT Value AS Value FROM Table (Value is an INTEGER column, stupid in this case to give it the same name, but you will see later why)

I get the expected result. But when I execute this query:

SELECT Value/1000 AS Value FROM table

The result is always 0 for every possible value. When I execute the following query:

SELECT Value/1000 FROM table

The result is OK. It seems that when I rename a column to a column that already exists in that table, the results is 0 when that column is an integer column and the results needs to be of type float

I first thought this would be a MySQL problem but with my previous components of zeos 6.1.5 this problem didn't occur. Could this be a zeos bug ? Or Am I doing something wrong ?

Thank you very much for a (quick) response!
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,

Did you define the columns in the IDE or are they created at runtime after the query was executed?? I tried to get this result but I did not succeed. Using mysql 5.1, but I don't expect a difference as long as the query returns the right result using the mysql console.
Eventually : can you send the test project (and db+data creation script)?

Mark
Image
christophe-marelec
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 27.03.2008, 10:46

Post by christophe-marelec »

Hi Mark,

I have created a little test project.

It seems that the result is 0 when I use ` or ' and when the column name is an INTEGER column of that table.

How can I send it to you ? I tried with pm but file size is limited to 512KB. it's about 1MB.

Regards,

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

Post by mdaems »

Solved by SVN rev. 362.
The reason for the problem : the quoted alias in 'SELECT Value/1000 AS `Value` FROM testtable' wasn't recognised as an alias.
Therefore, when the resultset from the server arrives, zeoslib tries to find the field definition of a field called 'value'. As this field exists in the table this fields definition is used, which certainly isn't correct when the field value is an integer and the resultset returns a float result. Now a quoted alias will be recognised, so the component knows there's no database field behind this calculation and it will not try to get the definition of a 'value' database field but uses the resultset's info about the field.

Mark
Image
Post Reply