> I notice the posting was dated back in 2004, now it's 2010 and I've come 
> across this article looking for a better way of choosing
> when an NULL value is entered into my SQL Server.
>
> I'm running CF9 and SQL Server I think is up to date as well (doesn't really 
> matter in this case I think)  Here's what I'm doing
> currently:
>
> < cfif isDefined( " form.myVal " ) >< cfqueryparam ... value="form.myVal" >< 
> cfelse >< cfqueryparam null="yes >< /cfif >
>
> Until today, I was content doing it, but, I started at this new company who 
> has not used cfqueryparams so we're having to go
> through all our websites and add this in for security purposes.  I wanted to 
> look around to the updated way of posting things and I
> wanted to check and see what NULL was.  I found this article and was happy to 
> see a shorter way of doing things.  I tried all the
> options mentioned and none of them worked.
>
> Anybody know why things aren't working?  If I cfparam the variables to 
> default="" then it will go through, but.. again... more work.  I
> might as well just keep to the cfif isDefined method.

The syntax you quoted in the email you found is incorrect. Simply use
a Boolean expression to evaluate the value of the NULL attribute of
CFQUERYPARAM. For example, if a field is present but may contain an
empty value:

<cfqueryparam ... null="#yesNoFormat(not len(trim(form.someField)))#">

Or, if a field may simply not be present:

<cfqueryparam ... null="#yesNoFormat(not structKeyExists(form, 'someField'))#">

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or o

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333281
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to