4 Replies Latest reply on Sep 10, 2009 5:11 AM by GArlington

    CFC Error on QoQ

    emmim44 Level 1

      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>

        • 1. Re: CFC Error on QoQ
          Dan Bracuk Level 5

          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.

          • 2. Re: CFC Error on QoQ
            emmim44 Level 1

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

            • 3. Re: CFC Error on QoQ
              Adam Cameron. Level 5

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

               

              --

              Adam

              • 4. Re: CFC Error on QoQ
                GArlington Level 1

                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>