House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search cf-talk

July 04, 2009

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Home /  Groups /  ColdFusion Talk (CF-Talk)

<cfqueryparam> question ("null" attribute)

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jamie Jackson
02/19/2004 02:38 PM

I'm not quite sure how the null attribute works in <cfqueryparam> =========================== From the docs: null [Optional] [Default="No"] Description: Whether parameter is passed as a null value. *Yes: tag ignores the value attribute *No =========================== Can anyone give me an example of the "null" attribute put to good use? Thanks, Jamie

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/19/2004 02:46 PM

The null attribute says that the value passed to the DB should be null, regardless of what the value attribute says.  For instance, if you have a select box with a blank first option and the actual options have a numeric value, you might use a CFQUERYPARAM like this: <cfqueryparam type="cf_sql_integer" value="#form.myVar#" isNull="#NOT isNumeric(form.myVar)#" /> That will insert the value provided, unless it's not numeric, in which case it'll insert NULL. Cheers, barneyb ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jamie Jackson
02/19/2004 03:16 PM

><cfqueryparam type="cf_sql_integer" value="#form.myVar#" isNull="#NOT >isNumeric(form.myVar)#" /> > >That will insert the value provided, unless it's not numeric, in which case >it'll insert NULL. Thanks Barney, One small correction though: I don't think CF can evaluate: #NOT isNumeric(form.myVar)# It seems you have to wrap "NOT {expression}" with a function, like: #yesNoFormat(NOT isNumeric(form.myVar))# Thanks, Jamie

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/19/2004 04:45 PM

It'll do it in CFMX, but not in CF5 and less.  Prior to CFMX, you could only have single values inside hashes, but with CFMX you can put arbitrary expressions between them. Cheers, barneyb ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tangorre, Michael
02/19/2004 02:41 PM

If it is set to YES, the value attribute is ignored and a NULL is used. If it is sent to NO, the value is used.   _____ Sent: Thursday, February 19, 2004 2:36 PM To: CF-Talk Subject: <cfqueryparam> question ("null" attribute) I'm not quite sure how the null attribute works in <cfqueryparam> =========================== From the docs: null [Optional] [Default="No"] Description: Whether parameter is passed as a null value. *Yes: tag ignores the value attribute *No =========================== Can anyone give me an example of the "null" attribute put to good use? Thanks, Jamie   _____  

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
02/19/2004 02:48 PM

----- Excess quoted text cut - see Original Post for more ----- Since CF and HTML don't have an idea of NULL, you may want to convert an empty string from an HTML form into a NULL value within the database. You could do it like this, I think: <cfqueryparam ... null="#YesNoFormat(NOT Len(Trim(Form.fieldname)))#"> Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ phone: 202-797-5496 fax: 202-797-5444

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jamie Jackson
02/19/2004 02:55 PM

>Since CF and HTML don't have an idea of NULL, you may want to convert an >empty string from an HTML form into a NULL value within the database. You >could do it like this, I think: > ><cfqueryparam ... null="#YesNoFormat(NOT Len(Trim(Form.fieldname)))#"> My situation exactly, thanks fellas. Thanks, Jamie

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew Walker
02/19/2004 04:21 PM

It will handle it in CFMX but not CF5. ><cfqueryparam type="cf_sql_integer" value="#form.myVar#" isNull="#NOT >isNumeric(form.myVar)#" /> > >That will insert the value provided, unless it's not numeric, in which case >it'll insert NULL. Thanks Barney, One small correction though: I don't think CF can evaluate: #NOT isNumeric(form.myVar)# It seems you have to wrap "NOT {expression}" with a function, like: #yesNoFormat(NOT isNumeric(form.myVar))# Thanks, Jamie   _____  


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists