Skip to main content
October 8, 2010
Question

Problems with MySQL query (Version 5) on Colfusion 9

  • October 8, 2010
  • 1 reply
  • 298 views

Hi,

I've got some problems on CF9 with few queries, it looks as if there was consersion type problem. (Drivers changes perhaps)

CF8 :                 SELECT IF(SUM(B.TOTALAMOUNT) IS NULL, "0.00", SUM(B.TOTALAMOUNT)) AS CA                  WHERE etc....

if i execute this query on CF8, the CA result is a string, on CF9 it's a binary.

So i've got to cast in the query to have the same result :

CF9 :                -  SELECT convert(IF(SUM(B.TOTALAMOUNT) IS NULL, "0.00", SUM(B.TOTALAMOUNT)), CHAR ) CA,                   WHERE etc....

Here my questions :

- Is it normal behaviour of CF9 ? may i forgot to add some parameters in Coldfusion Administrator (such Connection String or blob buffers size in the data source parameter) ?

- Is there an other way to resolve this problem ?

What 's more, when i use queryAddColumn(query1, columnName, type , Array) MSQL types seem not be the sames as in CF8 (Exemple :

CF8 : integer unsigned

CF9 : int unsigned)

I think this problem his linked to the first problem

Thanks a lot,

Ttroubat

    This topic has been closed for replies.

    1 reply

    Inspiring
    October 8, 2010

    I doubt the behavior has anything to do with CF. It is most like determined by the database driver.

    >> IF(SUM(B.TOTALAMOUNT) IS NULL, "0.00", SUM(B.TOTALAMOUNT))

    That sql seems to return a "string" in once case, and some sort of numeric data type in another. The mixed data types is bound to produce unexpected results. If you do not explicitly convert all of the values to the same data type, you are basically letting the database decide how to convert the results. If you do not want that to happen, you need to make sure all of the values have the same data type.

    Having said that, I think the COALESCE() function is more appropriate here. Same results, but with less code.

    ie SELECT SUM( COALESCE(B.TOTALAMOUNT, 0) )