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.