Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfqueryparam problem

Guest
Mar 05, 2012 Mar 05, 2012

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?

1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2012 Mar 05, 2012

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

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 05, 2012 Mar 05, 2012

The whole query is too much to put in here. Here is the line         ,cncode        =<cfqueryparam value="#cncode#" cfsqltype="CF_SQL_CHARACTER" maxlength="2">.

Works on test but not on real live.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 05, 2012 Mar 05, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2012 Mar 05, 2012

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/WSc3ff6d0ea77859461172e0811cbec22c24-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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 05, 2012 Mar 05, 2012

Thanks to you both. Guessing the invalid type is causing it.

Looking at program and have CF_SQL_CHARs until cncode which has the invalid type.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 07, 2012 Mar 07, 2012
LATEST

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 ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources