Posted to tcl by CecilWesterhof at Mon Jul 30 18:33:56 GMT 2018view raw

  1. I have the following code:
  2. set yesterdayAboveCountC {
  3. SELECT COUNT(*)
  4. , :tempAbove
  5. FROM temperature
  6. WHERE date = DATE('now', '-1 day')
  7. AND Temperature > :tempAbove
  8. }
  9. set yesterdayAboveCountD {
  10. SELECT COUNT(*)
  11. , :tempAbove
  12. FROM temperature
  13. WHERE date = DATE('now', '-1 day')
  14. AND Temperature > 65
  15. }
  16. puts [db eval ${yesterdayAboveCountC}]
  17. puts ################
  18. puts [db eval ${yesterdayAboveCountD}]
  19.  
  20. And this gives:
  21. 0 65
  22. ################
  23. 817 65
  24.  
  25. So it looks like thet :tempAbove is incorrectly expanded in the WHERE clause in yesterdayAboveCountC.
  26. What could be the reason of this?

Comments

Posted by CecilWesterhof at Mon Jul 30 19:29:57 GMT 2018 [text] [code]

It needs a CAST: AND Temperature > CAST(:tempAbove AS real)