Here is a situation where it is easier, in my opinion.
<cfquery name="NoVisit" dbtype="query"> select chart_no, patient_name, treatment_date, pr, BillingCompareField from BillingData where BillingCompareField not in (<cfqueryparam cfsqltype="cf_sql_varchar" value="#ValueList(FinalData.FinalCompareField)#" list="yes">) </cfquery>
An alternative would be to use a QuotedValueList. However, if anything in this list of values contains an apostrophe, cfqueryparam will escape it. Otherwise, I have to.
Editing starts here.
Here is another example where unused query parameters cause an error.
QueryAddRow(x,2); QuerySetCell(x,"dt",CreateDate(2001,1,1),1); QuerySetCell(x,"dt",CreateDate(2001,1,11),2); </cfscript> <cfquery name="y" dbtype="query"> select * from x where dt in (#ValueList(x.dt)#) </cfquery>
The written code causes this error:
Query Of Queries runtime error. Comparison exception while executing IN. Unsupported Type Comparison Exception: The IN operator does not support comparison between the following types: Left hand side expression type = "DATE". Right hand side expression type = "LONG".
With the request parameter commented above, the code succeeds.
source share