|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
<cfqueryparam> question ("null" attribute)
I'm not quite sure how the null attribute works in <cfqueryparam>Jamie Jackson 02/19/04 02:38 P The null attribute says that the value passed to the DB should be null,Barney Boisvert 02/19/04 02:46 P ><cfqueryparam type="cf_sql_integer" value="#form.myVar#" isNull="#NOTJamie Jackson 02/19/04 03:16 P It'll do it in CFMX, but not in CF5 and less. Prior to CFMX, you could onlyBarney Boisvert 02/19/04 04:45 P If it is set to YES, the value attribute is ignored and a NULL is used. IfTangorre, Michael 02/19/04 02:41 P > I'm not quite sure how the null attribute works in <cfqueryparam>Dave Watts 02/19/04 02:48 P >Since CF and HTML don't have an idea of NULL, you may want to convert anJamie Jackson 02/19/04 02:55 P It will handle it in CFMX but not CF5.Matthew Walker 02/19/04 04:21 P 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 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 ----- ><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 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 ----- 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 _____ ----- 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 >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 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 _____
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||