How not to code ColdFusion queries

I often make very silly mistakes that get me caught out and this one is no execption. I have just found this nice query in my codebase.

SELECT *
FROM TabReview
WHERE productID =
AND bActive = 1
Order by Title


Make no mistake, it is all mine! Yep, I was just too lazy to remove the * and put in all my column names. So imagine my surprise when my site stops working!

I had added another column to the db and all of a sudden my nice cfqueryparamed query was barfing all over the site!

Of course you know what was going on, CF had cached the execution plan of my query and now that the DB had changed all the columns were all over the shop. If only I had actualy put in all the column names instead of a * I would have been safe.
*sigh*

back to the coffee pot I go…

Advertisements
This entry was posted in General.