You should be able to nest cfquery in a cfloop that is not query based...
Maybe the actual problem is that cfloop doesn't implicitly force a cfoutput,
so chances are your variables are not getting resolved.  Include a
<cfoutput> inside the loop.

Here's a code snippet where I am nesting a query inside a loop:
<cfloop index="loop_index" from="1" to="#ArrayLen(jobs_time_spent)#">
 <cfoutput>

  <CFQUERY name="qry_job_rate" datasource="#application.dsn#">

   SELECT      dbo.Jobs.Jobs_Job_Name, dbo.Employee_Job_Rates.*
  FROM         {oj dbo.Jobs LEFT OUTER JOIN dbo.Employee_Job_Rates ON
dbo.Jobs.Jobs_ID = dbo.Employee_Job_Rates.Employee_job_rates_job_id }
  where Employee_job_rates_employee_id = #attributes.user_id#
  and dbo.Jobs.Jobs_Job_Name = '#jobs_names[loop_index]#'

 </CFQUERY>
.....
</cfoutput>
</cfloop>

The only other thing I could think of is the list attribute for cfloop.
Maybe cold fusion internally handles lists as a query.  Maybe just do a
"from to" loop and only do the query and related code when the index is in
the list.  That's what I am doing in the previous block of code, except with
arrays.

HTH,
-Bill
www.brainbox.tv

----- Original Message -----
From: "Kevin Gilchrist" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 11:38 AM
Subject: FW: Is it possible to nest CFQUERY inside CFLOOP?


> I just noticed the loop index variable is wrong, I changed it to from "i"
to
> "region" as it should be and still got the same error message...
>
> -----Original Message-----
> From: Kevin Gilchrist
> Sent: Thursday, May 31, 2001 11:32 AM
> To: CF-Talk (E-mail)
> Subject: Is it possible to nest CFQUERY inside CFLOOP?
>
>
> I get an error when I try to do this:
>
> <cfloop index="region" list="lst_region">
> <cfquery name="qry_Full_Week_Downtime_Region#i#" datasource="#DSN#"
> dbtype="Oracle80" cachedwithin="#CreateTimeSpan(0,1, 0, 0)#">
> SELECT
>   sum(severity_minutes) as sev_sum,
>   max(total_minutes)
> FROM
>   history_view,
>   site_name
> WHERE
>   query_id =259 AND
>   node='RS_CHARMING1' AND
>   severity=5 AND
>   customer_name='CHARMING' AND
>   application='RS_PING' AND
>   region=#i#
> </cfquery>
> </cfloop>
>
> The error message is:
>
> Just in time compilation error
> A nested CFQUERY tag has been encountered at document position (455:2) to
> (455:130). CFQuery tags cannot be nested inside one another.
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to