Skip navigation
Currently Being Moderated

Problem with empty string on insert

Mar 9, 2007 6:38 AM

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.
Thanks,
Brian
 
Replies
  • Currently Being Moderated
    Mar 9, 2007 7:43 AM   in reply to bpdevlin
    If the form field is a select, you are getting a value so using cfparam does not do anything for you. As you have already figured out, the value is an empty string.

    What is the datatype of the database field? If it is not char or varchar, that's your problem.
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2007 11:24 AM   in reply to bpdevlin
    Can you post the select tag code? It's hard to tell without looking at it.

    - Mike
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2007 1:43 PM   in reply to bpdevlin
    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.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points