Reputation: 25
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#">
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.
So the array issue is fixed, but I don't know how to fix the second error.
<cfdump var="#arguments.surveyDocNo#">
Upvotes: 0
Views: 181
Reputation: 7833
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#">
Upvotes: 4