Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building dynamic queries and outputing the results

Status
Not open for further replies.

Silvano

Programmer
Jul 16, 2001
386
US
When building dynamic query wher query gets name in using variable, I have problem outputing query RecordCount where the name of the query is variable

<cfset queryName = &quot;testing&quot;>

<cfquery name=&quot;#queryName#&quot; datasource=&quot;dataBaseName&quot;>
SELECT COUNT(fileSubCategory) as fileCount
FROM Background;
</cfquery>

<cfoutput>
Background Count: #RecordCount.<---I need here a variable value to be accepted:--->#queryName# #<br>
</cfoutput>

Is this possible scenario?
 
Hi sylvano,

I could be wrong on this, but what's the use of dynamic query names? Wouldn't it be better to make the SQL itself dynamic?

That way, you can always use the same recordcount variable without ever changing the code. All you do is build the SQL statement dynamically.

By the way, wont you get timing problems when declaring a query tag at runtime? Aren't those things supposed to be known before the page is actually parsing?

Hope to be of service :)

Gtz,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top