Hi,

> If I pass an empty field into a stored procedure like so:
> <cfstoredproc procedure="myProcedure" datasource="#Application.DSN#">
> <cfprocparam type="in" cfsqltype="cf_sql_integer"
> value="#FORM.CustNo#"> </cfstoredproc>
> I get:
> invalid data for cfsqltype cf_sql_integer.
> 
> Is that right?

Yes, thats right... "" is not an integer. ;-)

> What technique should I use?

<cfprocparam type="in" cfsqltype="cf_sql_integer" value="#FORM.CustNo#"
null="#YesNoFormat(NOT len(form.CustNo))#">

If "Yes", the null attribute allows to pass a NULL to a stored proc
(no matter if the variable you pass is empty or not!). 
If "No", the content of the variable in question is passed.

If form.CustNo is empty, then "NOT len(form.CustNo)" is true and
YesNoFormat() turns everything into null="yes"

If form.CustNo does contain a value, it's length is not 0 thus "NOT
len(form.CustNo)" is false and YesNoFormat sets null="no" and the param
passes the variable value.

Best, 

Chris



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to