Skip to main content
April 21, 2006
Answered

cfqueryparam ignores null="yes" when list="yes"

  • April 21, 2006
  • 1 reply
  • 293 views
I get an unexpected result when using cfqueryparam with list="yes" and null="yes" using CF 7.0.1 and MSSQL 2000.

When i run this code:
<cfset arguments.userIds = ""/>
<cfquery datasource="dsn">
select id
from users
where id in (<cfqueryparam value="#arguments.userIds#" cfsqltype="cf_sql_integer" list="true" null="#not listLen(arguments.userIds)#"/>)
</cfquery>

It throws an error:
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Line 3: Incorrect syntax near ')'.
SQL: select id from users where id in ()

If I remove list="yes" from the cfqueryparam tag, it works fine and sends "select id from users where id in (null)" to SQL server (which is a valid statement) and the page loads successfully. It appears that with list="yes" and null="yes", it does not send the "null" as I would expect like it does when list="no". I cannot find any documentation on using null="yes" with list="yes", so I can't tell if this is intended functionality or a bug. I am getting a SQL error, not a CF error, so CF sees it as syntactically correct.

Thanks.
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
Well it can't be a list if it's null, now can it?

Seriously, it looks like a bug to me.
You should file a bug report at: http://www.macromedia.com/support/email/wishform/ .

1 reply

Correct answer
April 22, 2006
Well it can't be a list if it's null, now can it?

Seriously, it looks like a bug to me.
You should file a bug report at: http://www.macromedia.com/support/email/wishform/ .