Our vBulletin migration is complete.
Welcome vBulletin users! All content and user information from the Micro Focus Forums (vBulletin) site has been migrated to this site. READ MORE.

MySql ODBC query returns incorrect value

MySql ODBC query returns incorrect value


When the following query is run from SilkTest using a MySQL ODBC, the query returns an incorrect value:

SELECT COUNT(*) FROM MyTable

In the above scenario where MyTable contains no records the value "48" is returned, whereas the actual value should be 0.

In the said scenario is appears that the MySQL ODBC driver is returning the ASCII character code for "0". This is a problem relating to the ODBC driver itself and is unrelated to SilkTest, however it is possible to modify the query to get the correct result. Using the SQL CAST function, we can convert the ASCII return value to the type CHAR to get the correct result as demonstrated below:

SELECT CAST(COUNT(*) AS CHAR) FROM MyTable

This will return a STRING representation of the return value, which can be converted to an integer using the SilkTest Val function.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 21:18
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.