If that doesnt work try

<cfif  evaluate(queryname & ".recordcount") eq 0>

(now I will sit back and wait for Raymond to present solution that doesn't
use evaluate ;} )


----- Original Message -----
From: "Douglas Brown" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, December 05, 2001 10:50 AM
Subject: Re: Stumped: Getting recordcount for dynamic query within a cfloop


> I may be way off.....hope not
>
>
> Can you do a
>
> <cfloop list="#queryName#" from="1" to="#listLen(queryName)#">
> <cfif #queryName#.recordCount eq "0">
> do this
> <cfelse>
> do this
> </cfloop>
>
>
>
> Doug
>
>
>
> ----- Original Message -----
> From: "Paul Sinclair" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, December 05, 2001 9:30 AM
> Subject: Stumped: Getting recordcount for dynamic query within a cfloop
>
>
> > I have a cfapp that is working fine except for one small item and I
> > can't figure out how to handle this piece of it. Simplest way to
> > describe the issue is probably to describe the two steps involved that
> > are giving me a problem.
> >
> > 1. Step 1
> >
> > This actually is not the problem area. What is done in the following
> > query cfloop is pretty simple - it just takes the results of an earlier
> > query, and then generates a series of new queries with the query names
> > based on a field from the earlier query.
> >
> > <cfloop query="categories">
> >
> > <cfoutput>
> > <cfset queryname = "#column_from_query#">
> > <cfquery name=#queryname# datasource="my_dsn">
> > select *
> > from newsletterItems
> > where newsletterID = #newsletterid# and newsletterHeadingID =
> > #newsletterheadingid#
> > </cfquery>
> > </cfoutput>
> >
> > </cfloop>
> >
> > After this code runs, I've got a series of 6 queries with names like
> > query1, query2, query3, query4, query5, query6.
> >
> >
> > 2. Step 2
> >
> > This is where I'm stumped. I want to loop through the same query as in
> > Step 1 ("categories") and then get an output of how many records were
> > returned for each query. So for "query1", how many records were found;
> > for "query2", how many records found; etc. If recordcount is 0, one
> > thing happens; if recordcount is not 0, another thing happens.
> >
> > What is baffling me is how I put together the names of the dynamic
> > queries (query1, query2, etc.) with the recordcount function so that I
> > will get the count? I've tried all sorts of combinations of hash signs,
> > quote signs, etc. but none is working. Here's the latest version, which
> > does not work. It is the sequence at lines 06 and 07 below that are the
> > problem.
> >
> > 01 <cfloop query="categories">
> > 02 <cfset queryName="#column_from_query#">
> > 03
> > 04 <cfoutput>
> > 05
> > 06 <cfif "#queryName#.recordcount" gte 1> DO THIS </cfif>
> > 07 <cfif "#queryName#.recordcount" lt 1>  DO THAT </cfif>
> > 08
> > 09 </cfoutput>
> > 10 </cfloop>
> >
> > Thanks for any help.
> >
> > Regards,
> > Paul Sinclair
> >
> >
> >
> >
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to