0

This is the first error that I am getting: Invalid data [d6-2014-74, , ] for CFSQLTYPE CF_SQL_VARCHAR

Here is the corresponding code.

 <cfset x = Arguments.surveyDocNo>
 <cfprocparam cfsqltype="cf_sql_varchar" value="#x#">

First Error Image:

To solve that problem, I changed my code to this:

 <cfset x = Arguments.surveyDocNo[1]>

However, that returns this error:

500 You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

Error 2

So the array issue is fixed, but I don't know how to fix the second error.

 <cfdump var="#arguments.surveyDocNo#">

enter image description here

7
  • 2
    In your first screen shot surveyDocNo is an Array but in your second screenshot it is a string. If you changed the variable to no longer be an array then you can go back to your original reference Arguments.surveyDocNo without the index value. Commented Nov 17, 2016 at 20:43
  • @Miguel-F Thanks for the quick response. Maybe I'm not understanding correctly, but when I go back to my original reference, it becomes an array again. Commented Nov 17, 2016 at 20:58
  • To avoid confusion, can you please dump the Arguments.surveyDocNo variable (not the whole structure) and post a screen shot. Commented Nov 17, 2016 at 21:30
  • @Leigh I added the information you requested. Commented Nov 17, 2016 at 21:39
  • 1
    Thanks. It clearly is an array, so I do not see how <cfset x = Arguments.surveyDocNo[1]> could possibly throw the error "...attempted to dereference a scalar variable". Seems like either different code is causing that error OR there is something more going on that we are aware of ...? Commented Nov 17, 2016 at 21:41

1 Answer 1

4

I assume you pass the surveyDocNo argument sometimes as string and sometimes as an array of strings.

<!--- if argument is passed as array, take the first element --->
<cfif isArray(Arguments.surveyDocNo) and (not arrayIsEmpty(Arguments.surveyDocNo))>
    <cfset x = Arguments.surveyDocNo[1]>
<cfelse>
    <cfset x = Arguments.surveyDocNo>
</cfif>

<!--- if the provided argument is not a string, throw an exception --->
<cfif not isSimpleValue(x)>
    <cfthrow type="IllegalArgumentException" message="The provided value for argument [surveyDocNo] is invalid. Expected a string.">
</cfif>

<cfprocparam cfsqltype="cf_sql_varchar" value="#x#">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.