CFQUERYPARAM is only useful for dynamic information.  It makes the
statements faster with most DBMSs (using prepared statements), and also
provides a level of security, because it prevents SQL injection attacks.
For any hard coded values (numbers, strings, whatever), you can use
CFQUERYPARAM if you want, but it's unnecessary.  NULL is a special case.
There is no way to use CFQUERYPARAM to pass a NULL to the database, so for
that 'value' (and that value alone) you HAVE to use it directly.  A good
tip-off is that the entire comparison is "IS NULL" or "IS NOT NULL", so
you'd actually have to pass multiple keywords.

So, the second form of the query you provided is the correct form, and the
only one that'll work.

barneyb
  -----Original Message-----
  From: Charlie Griefer [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, September 30, 2003 10:08 AM
  To: CF-Talk
  Subject: cfqueryparam and NULL values (SELECT)


  Hey all..

  trying to do the following query:

  SELECT *
  FROM tblCheckout
  WHERE
      videoID = <cfqueryparam value="#URL.videoID#"
cfsqltype="cf_sql_integer"> AND
      actual_returndate = <cfqueryparam value="" cfsqltype="cf_sql_date"
null="yes">

  i'm getting 0 records returned, where I know there is 1 record that
matches the criteria.

  I'm getting hung up on the actual_returndate value, where i'm searching
for a NULL.

  it works without <cfqueryparam>:

  SELECT *
  FROM tblCheckout
  WHERE
      videoID = <cfqueryparam value="#URL.videoID#"
cfsqltype="cf_sql_integer"> AND
      actual_returndate IS NULL

  returns the record i'm looking for.

  Am I using <cfqueryparam> wrong here?

  Thx!
  Charlie

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to