Skip navigation
lwfg
Currently Being Moderated

cfqueryparam problem

Mar 5, 2012 6:33 AM

The error template reports "The cause of this output exception was that: coldfusion.tagext.sql.QueryParamTag$InvalidDataException: Invalid data value 50 exceeds maxlength setting 2.."

The data comes a table where the field is longer than 2 but is trimmed before being assigned into an application variable and then put in a select-option element. On test system, foutputted len() of the variable and got 2.

The error happens on the real system but doesn't happen on the test system.

Hoping for permission to put same debug in real system.

 

What could cause this error?

 
Replies
  • Currently Being Moderated
    Mar 5, 2012 6:50 AM   in reply to lwfg

    Let's see the <cfquery> that's erroring...

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 5, 2012 7:21 AM   in reply to lwfg

    Why not just wrap the query up in a try/catch, and mail yourself the exact details and what data's going in? Clearly it's longer than two, else it wouldn't throw an error. No reason speculating, the value could be anything.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 5, 2012 7:23 AM   in reply to lwfg

    CF_SQL_CHARACTER is not a valid value in that situation.  You probably mean CF_SQL_CHAR.


    See the full list here:

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec22c24-7f6f.html

     

    As to why it's working at all, that's a bit of mystery, but I'd fix that just in case you're seeing a vagary of bad code rather than anything else.

     

    What you could be seeing is CF doing something odd with "50" when it converts it to an [unknown type], and because of its loose-typed-ness it ends up being "50.0" or something like that.  It might be down to which JVM version you're running on your various servers as to how it's handled.

     

    Use legit CFML code first and see if the problem goes away... if not, we can revisit...

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 7, 2012 2:50 PM   in reply to Adam Cameron.

    As to why it's working at all, that's a bit of mystery

     

    CF9 defaults to "char" when the type is invalid (possibly earlier versions too). So you could use cf_sql_foobar and it would just fall back to cf_sql_char anyway. Obviously you should stick with valid types or you lose some of the benefits ...

     
    |
    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