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!
Field of query result returns 0
Moderators: gto, cipto_kh, EgonHugeist
-
- Fresh Boarder
- Posts: 2
- Joined: 27.03.2008, 10:46
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
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
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
-
- Fresh Boarder
- Posts: 2
- Joined: 27.03.2008, 10:46
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
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
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