Tuesday, March 30, 2010

CFC Error on QoQ

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 :              %26amp; nbsp;      %26lt;cfloop from=''1'' to =''#listlen(application.Sql_SC)#'' index=''i''%26gt;
14 : %26amp; nbsp; union
15 : %26amp; nbsp; %26lt;cfquery name=''GetZone#i#'' datasource=''#i#''%26gt;
16 : %26amp; nbsp; SELECT ccflocationID, Location_Name
17 : %26amp; nbsp; FROM ccflocation

---------------

%26lt;cfcomponent hint=''This cfc goes to Scorecard environment and grabs some stuff''%26gt;
%26lt;cffunction name=''Zone'' access=''public'' returntype=''Query''%26gt;

%26lt;cfset myLoc = QueryNew(''ccflocationID,Location_Name'', ''Integer,VarChar'')%26gt;


%26lt;cfargument name=''DSN'' required=''true'' type=''string''%26gt;
%26lt;cfquery dbtype=''query'' name=''GetZone''%26gt;
select ccflocationID, Location_Name from myLoc
%26lt;cfloop from=''1'' to =''#listlen(arguments.DSN)#'' index=''i''%26gt;
?union
?%26lt;cfquery name=''GetZone#i#'' datasource=''#i#''%26gt;
SELECT ccflocationID, Location_Name
FROM ccflocation
?%26lt;/cfquery%26gt;
%26lt;/cfloop%26gt;
%26lt;/cfquery%26gt;

%26lt;cfreturn GetZone%26gt;
%26lt;/cffunction%26gt;

?
%26lt;/cfcomponent%26gt;

CFC Error on QoQ

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.

CFC Error on QoQ

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

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

--

Adam

You can NOT mix QoQ and DB queries together...

this is QoQ

%26lt;cfquery dbtype=''query'' name=''GetZone''%26gt;
...

this is DB query

%26lt;cfquery name=''GetZone#i#'' datasource=''#i#''%26gt;

You will need to run your DB queries first (outside QoQ)

and then run the loop again to UNION all results...

%26lt;cfloop from=''1'' to =''#listlen(arguments.DSN)#'' index=''i''%26gt;
%26lt;cfquery name=''GetZone#i#'' datasource=''#i#''%26gt;
?SELECT ccflocationID, Location_Name
?FROM ccflocation
%26lt;/cfquery%26gt;
%26lt;/cfloop%26gt;

%26lt;cfquery dbtype=''query'' name=''GetZone''%26gt;
select ccflocationID, Location_Name from myLoc
%26lt;cfloop from=''1'' to =''#listlen(arguments.DSN)#'' index=''i''%26gt;
?union
select ccflocationID, Location_Name from GetZone#i#
%26lt;/cfloop%26gt;
%26lt;/cfquery%26gt;

No comments:

Post a Comment