Copy link to clipboard
Copied
Error:
Error casting an object of type to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.
The error occurred in C:\Inetpub\wwwroot\RMS\Untitled-3.cfm: line 15 | |
13 : <cfloop from="1" to ="#listlen(application.Sql_SC)#" index="i"> 14 : union 15 : <cfquery name="GetZone#i#" datasource="#i#"> 16 : SELECT ccflocationID, Location_Name 17 : FROM ccflocation |
---------------
<cfcomponent hint="This cfc goes to Scorecard environment and grabs some stuff">
<cffunction name="Zone" access="public" returntype="Query">
<cfset myLoc = QueryNew("ccflocationID,Location_Name", "Integer,VarChar")>
<cfargument name="DSN" required="true" type="string">
<cfquery dbtype="query" name="GetZone">
select ccflocationID, Location_Name from myLoc
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
union
<cfquery name="GetZone#i#" datasource="#i#">
SELECT ccflocationID, Location_Name
FROM ccflocation
</cfquery>
</cfloop>
</cfquery>
<cfreturn GetZone>
</cffunction>
</cfcomponent>
Copy link to clipboard
Copied
You are trying to ignoring what I told you in the other thread and attempting to combine Q of Q and database queries. You have to do them separately.
Copy link to clipboard
Copied
I am not ignoring you Dan, I followed your recipe and ends up here... what else not in place???
Copy link to clipboard
Copied
See my reply in the other thread you raised about this problem.
--
Adam
Copy link to clipboard
Copied
You can NOT mix QoQ and DB queries together...
this is QoQ
<cfquery dbtype="query" name="GetZone">
...
this is DB query
<cfquery name="GetZone#i#" datasource="#i#">
You will need to run your DB queries first (outside QoQ)
and then run the loop again to UNION all results...
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
<cfquery name="GetZone#i#" datasource="#i#">
SELECT ccflocationID, Location_Name
FROM ccflocation
</cfquery>
</cfloop>
<cfquery dbtype="query" name="GetZone">
select ccflocationID, Location_Name from myLoc
<cfloop from="1" to ="#listlen(arguments.DSN)#" index="i">
union
select ccflocationID, Location_Name from GetZone#i#
</cfloop>
</cfquery>