Terribly sorry...I messed up the CFIF statement. The NULL should be applied if an empty field is detected. Should read:
<cfstoredproc procedure="myProcedure" datasource="#Application.D
<cfif len(FORM.CustomerNo) is 0>
<cfprocparam type="in" cfsqltype="cf_sql_integer"
<cfelse>
<cfprocparam type="in" cfsqltype="cf_sql_integer"
</cfif>
</cfstoredproc>
Sorry for the confusion.
Main Topics
Browse All Topics





by: pmascariPosted on 2006-03-02 at 18:39:54ID: 16091342
This is the correct behavior because your telling CF to form its SQL as if there were to be an integer in #FORM.CustomerNo#. So, for example, the SQL could look like:
SN#" debug="yes" returncode="yes"> value="#FORM.CustomerNo#"> value="#FORM.CustomerNo#" null="Yes">
SELECT * FROM TABLE1 WHERE CustomerNo = #FORM.CustomerNo#;
This will translate to
SELECT * FROM TABLE1 WHERE CustomerNo = ;
on your database. Assuming CustomerNo is an integer field you can see why this produces an error. If CustomerNo were a VARCHAR field, however, you could pass an empty field (making sure to change your CFSQLTYPE to CF_SQL_VARCHAR) and the SQL would end up like:
SELECT * FROM TABLE1 WHERE CustomerNo = '';
which would be valid.
If you need to keep the DB field as an integer you should probably pass in a null value rather than an empty space like so:
<cfstoredproc procedure="myProcedure" datasource="#Application.D
<cfif len(FORM.CustomerNo) is 0>
<cfprocparam type="in" cfsqltype="cf_sql_integer"
<cfelse>
<cfprocparam type="in" cfsqltype="cf_sql_integer"
</cfif>
</cfstoredproc>