House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   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       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

<cfqueryparam> question ("null" attribute)

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 

02/19/2004 02:38 PM
Author:
Jamie Jackson

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

02/19/2004 02:46 PM
Author:
Barney Boisvert

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

02/19/2004 03:16 PM
Author:
Jamie Jackson

><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

02/19/2004 04:45 PM
Author:
Barney Boisvert

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

02/19/2004 02:41 PM
Author:
Tangorre, Michael

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.   _____   From: Jamie Jackson [mailto:jacksonj@calib.com] 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   _____  

02/19/2004 02:48 PM
Author:
Dave Watts

> I'm not quite sure how the null attribute works in <cfqueryparam> 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

02/19/2004 02:55 PM
Author:
Jamie Jackson

>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

02/19/2004 04:21 PM
Author:
Matthew Walker

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