I think the point is that if you're going to use any of those techniques,
you DO have to param the variable, or use some other mechanism to make sure
the variable exists. Otherwise the code in your "value" attribute will
always fail when the variable doesn't exist. Make sense?

On Mon, May 3, 2010 at 11:12 AM, Matthew Lowrey <[email protected]> wrote:

>
> This is getting to be quite an interesting challenge.  All the examples
> I've seen logically make sense but none of them have worked so far.  I will
> say I'm learning quite a bit from everyone's knowledge/wisdom.  I will try
> and list here all the different methods I've tried out and have failed.
>  First, the method I've used (and still using):
>
> <cfif isDefined("form.myVal")><cfqueryparam cfsqltype="cf_sql_varchar"
> value="#form.myVal#" maxlength="50"><cfelse><cfqueryparam null="yes"></cfif>
>
> Examples that have not worked (unless I cfparam the variable):
>
> <cfqueryparam value="#form.myVar#" null='#not IsDefined("form.myVar")#'>
> <cfqueryparam value="#form.myVar#" null="#not IsDefined('form.myVar')#">
> <cfqueryparam value="#form.myVar#" null="#not IsDefined('form.myVar')#">
> <cfqueryparam value="#form.myVar#" null="#not Len(Trim(form.myVar))#" />
> <cfqueryparam type="cf_sql_varchar" value="#form.myVar#" isNull="#NOT
> isDefined(form.myVar)#" /> (actually got a different error on this one and
> couldn't figure it out for some reason  Attribute validation error for tag
> CFQUERYPARAM. Usually it's because I'm passing the wrong cf_sql_type, but I
> took that out and it still gave me the error)
> <cfqueryparam type="cf_sql_varchar" value="#form.myVar#"
> isNull="#yesNoFormat(NOT isDefined(form.myVar)#" />
> <cfqueryparam type="cf_sql_varchar" value="#form.myVar#"
> isNull="#YesNoFormat(NOT Len(Trim(form.myVar)))#" />
> <cfqueryparam type="cf_sql_varchar" value="#form.myVar#"
> isNull="#yesNoFormat(not structKeyExists(form, 'myVar'))#" />
> <cfqueryparam type="cf_sql_varchar" value="#form.myVar#"
> isNull="#yesNoFormat(not len(trim(form.myVar)))#" />
>
> I went ahead and re-tried all these examples above.  Most (if not all)
> these examples should work logically.  Also, for the record I'm currently
> using:
> Coldfusion 9
> SQL Server 2005
>
> Thank again for everybody's help and wisdom!
>
> Best Regards
> Matt..
>
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:333294
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to