Skip to main content
Inspiring
September 8, 2009
Question

CFC Error on QoQ

  • September 8, 2009
  • 2 replies
  • 917 views

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>

This topic has been closed for replies.

2 replies

September 10, 2009

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>

Inspiring
September 8, 2009

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.

emmim44Author
Inspiring
September 8, 2009

I am not ignoring you Dan, I followed your recipe and ends up here... what else not in place???

Inspiring
September 8, 2009

See my reply in the other thread you raised about this problem.

--

Adam