I believe you may be getting the scopes confused. Cached querys are for most intents and purposes stored in some place equivalent to the application scope. Your query also suggests that the information being pulled is specific to the application, not the user (session). If there is not any information coming back from the query specific to the user then I don't see a problem...
If the query does actually have user specific information, you may be better off just adding a userid field to the query. Caching it isn't a problem then. <cfquery datasource="#request.dsn#" name="qGetSite"> SELECT sitename FROM tblSites WHERE siteID=#session.siteID# AND userID=#session.userID# </cfquery> Is siteid actually a property of the user or the application? If it's a property of the application as the name siteID suggests, then store it in the application scope. That may in and of itself help answer your question without getting into dynamically naming queries, which is possible, but I'd avoid that scenario if possible. I do want to mention that I use cached queries to store user information all the time. I think it's a great way to sidestep locking, and increase performance at the same time. -- jon mailto:[EMAIL PROTECTED] Thursday, January 16, 2003, 1:24:30 PM, you wrote: JM> Ok, I've been reading up on query caching today and I think I've run JM> into something that may cause me problems unless there is a way to JM> dynamically name queries. JM> I have an application that houses data for multiple "sites" - the data JM> is referenced by a siteID that is set as a session variable. JM> So for example: JM> <cfquery datasource="#request.dsn#" name="qGetSite"> JM> SELECT sitename JM> FROM tblSites JM> WHERE siteID=#session.siteID# JM> </cfquery> JM> If I try to cache this query, then if someone logs in with a siteID of JM> 20 then they'll get their data, unless the query is cached, then they'll JM> get the data of whoever logged in the last time - no matter what their JM> siteID correct? JM> Is there a way to create a dynamic queryname? JM> I tried: <cfquery datasource="#request.dsn#" JM> name="qGetSite#session.siteID#"> and it worked to create the query, but JM> for subsequent references I'm getting errors like on: JM> This errors: <cfif qGetSite#session.siteID#.recordcount GT 0> JM> This errors: <cfset queryct="qGetSite#session.siteID#.recordcount"> JM> <cfif evaluate(queryct) GT 0> JM> Is there a way I can dynamically name my query so that I can use query JM> caching without giving users the wrong data? JM> Can I turn off all query caching and then specify queries to cache using JM> the CACHEDWITHIN statement for queries that don't rely upon the siteID? JM> Thanks, JM> Joshua Miller JM> Head Programmer / IT Manager JM> Garrison Enterprises Inc. JM> www.garrisonenterprises.net <http://www.garrisonenterprises.net/> JM> [EMAIL PROTECTED] JM> (704) 569-9044 ext. 254 JM> ************************************************************************ JM> ************* JM> Any views expressed in this message are those of the individual sender, JM> except where the sender states them to be the views of JM> Garrison Enterprises Inc. JM> This e-mail is intended only for the individual or entity to which it is JM> addressed and contains information that is private and confidential. If JM> you are not the intended recipient you are hereby notified that any JM> dissemination, distribution or copying is strictly prohibited. If you JM> have received this e-mail in error please delete it immediately and JM> advise us by return e-mail to JM> <mailto:[EMAIL PROTECTED]> JM> [EMAIL PROTECTED] JM> ************************************************************************ JM> ************* JM> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

