Wow, I had sent this a long time before it arrived (sent at 10:12) well
before Ajas replied to Derrick and Teddy. Sorry. Don't know why it got held
up (as did a few messages of mine to the list, which all arrived around 12).
Odd.

 

/charlie

 

From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Charlie Arehart
Sent: Thursday, February 04, 2010 10:12 AM
To: discussion@acfug.org
Subject: RE: [ACFUG Discuss] Query or Stored Proc calling

 

Ajas, given your experience with CF, I'm a little confused how to reply. If
this was a brand new user, I'd say that they have things backward and even
then still misunderstood.

First, the main difference is that the code in blue would execute once for
each query result, whereas the code in red would execute only once, for the
first record in the result set. Also, you go on to refer to things in terms
of "executing the query" more than once, but that never happens in either
example. The query is executed only once (unless the cfquery itself us
somehow in another loop). The difference is only a matter of whether the
query's results are looped over (first example) or not (second example).

Second, it seems that you're maybe thinking that the use of the queryname
before the column name has some affect on how many records are processed,
but it does not. It's simply that if (in the first example) you're in a
CFQUERY output loop, the queryname is optional (though recommended) as CF
can figure out that the varname is a reference to a query column name
because the queryname becomes a sort of default scope for the life of the
query loop. But in the plain cfoutput (the second example, which is not a
loop), then the queryname is not a part of the normal scope search, so CF
would not know that the variable references were query columns, so you must
provide them.

Finally, none of this changes if it's a cfstoredproc/cfprocresult or a
cfquery. 

Does that help? Or is there something more to your question that I'm not
seeing? 

 

/charlie

 

From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Ajas Mohammed
Sent: Wednesday, February 03, 2010 10:21 PM
To: discussion@acfug.org
Subject: [ACFUG Discuss] Query or Stored Proc calling

 

Hi,

I came across code like this

<cfquery name="getSomething" datasource="test">
   select col1,col2,col3 from tbl where condition
</cfquery>

Now, instead of using <cfoutput query="getSomething"> col1 <br /> col2 <br
/> col3 <br /> </cfoutput>,
the code uses <cfoutput>getSomething.col1 <br /> getSomething.col2 <br />
getSomething.col3 <br /> </cfoutput>

The code in blue would do ONLY ONE CALL to query and display results.

My take is that, the code in red is executing the query every time col1 thru
col3 are referenced with query name. Is this correct? Also if getSomething
was a cfprocresult name, the stored proc would be executed for every
reference to stored proc name.colname right?

Thanks,

<Ajas Mohammed />
http://ajashadi.blogspot.com
We cannot become what we need to be, remaining what we are.
No matter what, find a way. Because thats what winners do.
You can't improve what you don't measure.
Quality is never an accident; it is always the result of high intention,
sincere effort, intelligent direction and skillful execution; it represents
the wise choice of many alternatives.


------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform 

For more info, see http://www.acfug.org/mailinglists 
Archive @ http://www.mail-archive.com/discussion%40acfug.org/ 
List hosted by FusionLink <http://www.fusionlink.com>  
------------------------------------------------------------- 




-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to