Skip to main content
April 12, 2011
Answered

cfqueryparam-testing for null

  • April 12, 2011
  • 1 reply
  • 1564 views

select * from table1 where id=<cfqueryparam value="#id#" cfsqltype="CF_SQL_CHAR" maxlength="30"> and date1 is not null

In that query, is cfqueryparam needed for date1 eventhough a value isn't being used ?

    This topic has been closed for replies.
    Correct answer recursivecodes

    <cfqueryparam null="true" /> should be all that you need to do.

    1 reply

    Participating Frequently
    April 12, 2011

    The side benefit of using cfqueryparam, as I understand it, is that the  execution plan will be cached (therefore making the query faster the  next time you run it).  I could be wrong, but that's why I tend to  always use cfqueryparam even for static values.

    April 12, 2011

    Thank you for the reply. When I set the value attrib to null, Coldfusion gives an invalid type error. How is this done right ?

    recursivecodesCorrect answer
    Participating Frequently
    April 12, 2011

    <cfqueryparam null="true" /> should be all that you need to do.