Simple. You may only want to run the query if a specific variable exists, such as a form field, or a fuseaction.
-- Snake -----Original Message----- From: Aaron Rouse [mailto:[EMAIL PROTECTED] Sent: 03 October 2006 20:27 To: CF-Talk Subject: Re: CFIF Statement I have seen this done before as well but it still does not answer my question fully. What is a scenario where someone has a page coded in a way that a query may not exist yet they always have outputs or other conditional logic present for it existing? Seems strange to me to have something like: <cfif some condition> <cfquery name="myquery" .... > </cfif> <cfif StructKeyExists(VARIABLES, "myquery")> do something here </cfif> If anything I could see how in between those two CFIFs are these huge amounts of other pieces of code but seems like <cfif some condition> would just be used on both if statements. That seems strange because I'd thought if there is a <cfif some condition> for a query to run then there is a <cfelse> for when it is not present. Or does this all relate back to the IsBeer() function ... On 10/3/06, Teddy Payne <[EMAIL PROTECTED]> wrote: > > If a query does not exist, I have seen a common implementation that > you build a query with the same columns names as you would expect from > the query and replace the values with error codes. > > The other end would be to <cfthrow> an error and have the error > handler of your choice handle the event. > > Teddy > > On 10/3/06, Aaron Rouse <[EMAIL PROTECTED]> wrote: > > > > Out of curiosity what do you present the user when the query is not > > defined? Or to reword that question, what is a scenario where you > > could be dealing with outputting on a query that may or may not > > exist? > > > > On 10/3/06, loathe <[EMAIL PROTECTED]> wrote: > > > > > > I usually leave it at: > > > > > > <cfif isDefined("myQuery") and myquery.recordCount> > > > > > > How is that not clear enough? I mean, if I haven't created the > > > query > it > > > doesn't run. If my naming convention is good there won't be > > > anything > > else > > > named myQuery floating around to break this condition. > > > > > > > -----Original Message----- > > > > From: Aaron Rouse [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, October 03, 2006 11:52 AM > > > > To: CF-Talk > > > > Subject: Re: CFIF Statement > > > > > > > > And what if qryName does not even exist? Should it not start > > > > off > with > > > a: > > > > StructKeyExists(VARIABLES, "qryName") After we know it exists > > > > and > we > > > know > > > > it is a query then we can assume recordcount exists and do the > boolean > > > > checks. > > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255269 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

