Regarding Static Variables in SQL Statements
In my last post I indicated that even static variables passed to SQL statements should be bound using Cfqueryparam. My understanding was that the DB server could only create cached plans if all the variables in the statement were bound - so I believed that a statement like the following:
<cfquery>
SELECT fname, lname
FROM users
WHERE active = 1
</cfquery>
...Could not benefit from the execution plan cache. In the comments of the
previous post a number of people disputed this idea, saying that if the variable is static it will cause the execution plan to be cached. Now, Chris Secord has given me a tip on how to prove that I am wrong.
[More]