Using CFMX7, I am running into a problem with inserts of an
empty string. There is a user form that passes data to a second
form to do the record insert. For the SQL insert, I am using
cfqueryparam to specify the input values. The text for the field in
question is pulled from a dropdown list on the input form. It works
fine when a user selects a value but if the dropdown select is left
unselected, the user gets a database error: THE LENGTH OF INPUT
HOST VARIABLE NUMBER 003 IS NEGATIVE OR GREATER THAN THE MAXIMUM. I
have a cfparam statement on the insert page to default the value to
(type="string" default="") since not selecting the dropdown will
result in the form field not being passed.
The debug output shows (param 3) = [type='IN',
class='java.lang.String', value='', sqltype='cf_sql_char'] so it
looks like the value is getting passed to the database as an empty
string. Does anybody have an idea of the problem? The backend
database is DB2 OS/390 v.7.
Dan Bracuk, Mar 9, 2007 1:43 PM
The target database field is a char so that's not the
problem. Forgot to mention that the insert will eventually work.
The user will initially get the error but if they resubmit, the
data eventually gets inserted so this is really confusing.
page that disables the dropdown depending on the state of another
checkbox on the form.
What happens when you attempt the insert outside of cold
fusion? I assume you have debugging turned on so you can see the
sql that is being sent to the db. Ya never know, maybe it's a
different field that's causing the problem.