Just had a long talk with Sean about that. Not do-able (other than it looking ugly). Doing an initial CFSET with the var key word is the way to go.
> Would it be possible to do <cfquery name="var getEmployees"> ? It looks > funny and I doubt it would work, but I know you can do <cfquery > name="application.getEmployees"> so I thought maybe the other would work > as well. Anyone have time to test? > > John > > -----Original Message----- > From: Michael Dinowitz [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 11, 2004 12:51 PM > To: CF-Talk > Subject: RE: Function and query name overwrite > > Very interesting. I'd never have thought of doing a var set before the > CFQUERY. It would show up in my head as an unnecessary operation. I > think MM should add in an attribute to all tags that return data to make > the data location specific. > <CFQUERY name="qName" datasource="#DSN#" local="yes"> > > > If you scope your query as local to the function, the conflict will do > > > away. It's BP for thread safety, etc.: > > > > Instead of: > > > > <cffunction name="getEmployees"> > > <cfquery name="getEmployees">... > > </cffunction> > > > > Do: > > > > <cffunction name="getEmployees"> > > <cfset var getEmployees=""> > > <cfquery name="getEmployees">... > > </cffunction> > > > > > > On Thu, 11 Nov 2004 12:28:35 -0500, Michael Dinowitz > > <[EMAIL PROTECTED]> wrote: > > > This is not a question, just something I ran into that was > interesting. > > > > > > Just a small thing I ran into. I'm working with a CFC that has a > > function in > > > it called Dupe_Address. This function is called twice in a row. > > > Inside > > the > > > function is a query of the same name. When the function is called a > > second > > > time, I get an error. Why? > > > Because the query having the same name as the function 'overwrites' > > > it > > and > > > the second call to the function fails. I thought that functions > > > could > > not > > > have the name of variables (I.e. things in the variables scope). > > > Never > > knew > > > a query would screw it up. > > > All I had to do in order to fix it was change the query name by > > > adding a > > q > > > before the name (my personal standard). > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184016 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54