Thanks Teddy and Derrick. Good to know that I was wrong in my assumption. I felt <cfoutput>getSomething.col1 <br /> getSomething.col2 <br /> getSomething.col3 <br /> </cfoutput> is an overkill but apparently not.
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. On Thu, Feb 4, 2010 at 10:22 AM, Teddy R. Payne <[email protected]>wrote: > Ajas, > I am not sure what you are looking for here. > > Given your example: > > <cfquery name="getSomething" datasource="test"> > select col1,col2,col3 from tbl where condition > </cfquery> > > If you perform: > > <cfoutput>#getSomething.col1#</cfoutput> > > You will get back "col1" from the first record. The call to the database > does not occur in the cfoutput. The call happens in the <cfquery> and will > stay available for the life of template execution. > > As for stored procedures, you can call stored procedures within <cfquery> > using syntax for your associated RDMS(EXEC...etc). I have not been a fan of > that practice as I typically favor <cfstoredproc>. If you need multiple > result sets, <cfprocparam> has a "resultset" attribute that you can assign. > "Resultset" is an integer and it refers to the logically produced data sets > in your stored procedure from top to bottom in that order. > > As with above, <cfoutput> does not call the stored procedure. The stored > procedure would be called within <cfquery> or <cfstoredproc> and stored in > the variables scope unless otherwise created. <cfoutput> can "bind" to a > query using the "query" attribute of <cfoutput> to the resultset of a > storedprocedure or a query by the reference to the name of the result set or > query name, but only in the sense of outputting the information stored in > the returned data that is stored in the variable. > > > Teddy R. Payne, ACCFD > Google Talk - [email protected] > > > > > On Wed, Feb 3, 2010 at 10:20 PM, Ajas Mohammed <[email protected]> wrote: > >> 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. >> > >
