RE: Dynamic queries within a loop
I don't know if this will make a difference, but try using alternating quote types. Like this: Might make a difference. -Original Message- From: Torrent Girl [mailto:moniqueb...@gmail.com] Sent: Tuesday, May 06, 2014 10:32 AM To: cf-talk Subject: Re: Dynamic queries within a loop Thanks. Here is how I am dumping the dynamic queries: ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358567 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
>> I am not understanding the variables part? >> >> Do I create a local var? Can you give me the exact syntax? > >Every variable scope in CF can be treated as a structure. So, if you do this: > > > >it's equivalent to doing this: > > > >and this: > > > >The last example shows a literal string being used to create the >variable name. You can build literal strings from CF expressions: > > > > >That's what Bobby did in his example. > Thanks. Here is how I am dumping the dynamic queries: ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358566 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
> I am not understanding the variables part? > > Do I create a local var? Can you give me the exact syntax? Every variable scope in CF can be treated as a structure. So, if you do this: it's equivalent to doing this: and this: The last example shows a literal string being used to create the variable name. You can build literal strings from CF expressions: That's what Bobby did in his example. Dave Watts, CTO, Fig Leaf Software 1-202-527-9569 http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358364 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
>errr Variables["getCourse" & I].CREDITDESIGNATIONTO > >One of those bad boys. > > > >On 4/18/14, 10:28 AM, "Bobby" wrote: > >> Hi Bobby I am not understanding the variables part? Do I create a local var? Can you give me the exact syntax? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358363 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
>errr Variables["getCourse" & I].CREDITDESIGNATIONTO > >One of those bad boys. > > > >On 4/18/14, 10:28 AM, "Bobby" wrote: > >> Thanks ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358362 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
errr Variables["getCourse" & I].CREDITDESIGNATIONTO One of those bad boys. On 4/18/14, 10:28 AM, "Bobby" wrote: > >Variables["getCourse" & i & ".CREDITDESIGNATIONTO©÷] > > >On 4/18/14, 9:42 AM, "Torrent Girl" wrote: > >> >>This actually worked for me: #evaluate("getCourse" & i & >>".CREDITDESIGNATIONTO")# >> >>but of course everyone will tell me not to use evaluate. >> >>How can I rewrite this properly? >> >> >> > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358361 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
Variables["getCourse" & i & ".CREDITDESIGNATIONTO²] On 4/18/14, 9:42 AM, "Torrent Girl" wrote: > >This actually worked for me: #evaluate("getCourse" & i & >".CREDITDESIGNATIONTO")# > >but of course everyone will tell me not to use evaluate. > >How can I rewrite this properly? > > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358360 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
This actually worked for me: #evaluate("getCourse" & i & ".CREDITDESIGNATIONTO")# but of course everyone will tell me not to use evaluate. How can I rewrite this properly? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358359 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
> Perhaps you do a cfset above the second proc > > > > Then reference that in the tag > > > > the thing that's popping out to me is your "in" params > > cfsqltype="CF_SQL_DATE" > variable="fromDate" > value="#getCourse#i#.CREDITDESIGNATIONFROM#"> > cfsqltype="CF_SQL_DATE" > variable="toDate" > value="#getCourse#i#.CREDITDESIGNATIONTO#"> > > something looks very wrong here. Like you almost want to dynamically > evaluate a queryname > > #eval("getCourse" & i & ".CREDITDESIGNATIONTO")# > > (BTW, the proc result of the previous proc is "course#i#", which might > also be at issue with defining your second related proc) > > The bigger thing I'm wondering is why you really require two separate > procs. In most of the cases of this that I have seen, two procs could > be written as one through proper usage of joins, and save you some > overhead (and headaches). > > > Steve 'Cutter' Blades > Adobe Community Professional > Adobe Certified Expert > Advanced Macromedia ColdFusion MX 7 Developer > > http://cutterscrossing.com > Thanks for your reply Steve. The 2nd query, the one that looks wrong to you is the one I am asking for help on. :) I need to use dynamic vars (based on the first query) but I don't know the syntax. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358358 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Dynamic queries within a loop
Perhaps you do a cfset above the second proc Then reference that in the tag the thing that's popping out to me is your "in" params something looks very wrong here. Like you almost want to dynamically evaluate a queryname #eval("getCourse" & i & ".CREDITDESIGNATIONTO")# (BTW, the proc result of the previous proc is "course#i#", which might also be at issue with defining your second related proc) The bigger thing I'm wondering is why you really require two separate procs. In most of the cases of this that I have seen, two procs could be written as one through proper usage of joins, and save you some overhead (and headaches). Steve 'Cutter' Blades Adobe Community Professional Adobe Certified Expert Advanced Macromedia ColdFusion MX 7 Developer http://cutterscrossing.com Co-Author "Learning Ext JS 3.2" Packt Publishing 2010 https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book "The best way to predict the future is to help create it" On 4/17/2014 11:36 AM, Torrent Girl wrote: > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358345 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm