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

CFC Error on QoQ

Participant ,
Sep 08, 2009 Sep 08, 2009

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>

TOPICS
Advanced techniques
822
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 ,
Sep 08, 2009 Sep 08, 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.

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
Participant ,
Sep 08, 2009 Sep 08, 2009

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

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 ,
Sep 08, 2009 Sep 08, 2009

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

--

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
Sep 10, 2009 Sep 10, 2009
LATEST

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>

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