Nested Query Loop Bug/Issue

2003-03-27 Thread Tony Schreiber
I don't know if any of you have run into this before or if it's even been
mentioned (couldn't find it at mm technotes either), but I've run into a
situation where the values of an outer loop referred to in an inner loop
are not what you expect. I was burned on this recently and remember
vaguely it happening to me before. I've written some demonstration code to
illustrate:

http://www.simplemessageboard.com/loopbug.cfm

The solution as shown in the code is to set a local variable BEFORE you
begin the inner loop to hold the value of the outer loop you want to refer
to within the inner loop.

Anyone had this happen? Or is this expected behavior that I can't see?

BTW, this is CF5, I don't know about MX.


Tony Schreiber, Senior Partner  Man and Machine, Limited
mailto:[EMAIL PROTECTED]   http://www.technocraft.com

http://www.is300.net The Enthusiast's Home of the Lexus IS300 since 1999
http://www.simplemessageboard.comFree Forum Software for Cold Fusion

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Nested Query Loop Bug/Issue

2003-03-27 Thread Randell B Adkins
I have seen it before, not sure why it happens but what I did
to solve it was set a temp variable to hold the first element of
the query and reset it when it changes.

cfset tempvar = ''
cfoutput query=myQuery
 cfif tempvar NEQ myQuery.Value1
cfset tempvar = myQuery.Value1
/cfif

...


 [EMAIL PROTECTED] 03/27/03 12:04PM 
I don't know if any of you have run into this before or if it's even
been
mentioned (couldn't find it at mm technotes either), but I've run into
a
situation where the values of an outer loop referred to in an inner
loop
are not what you expect. I was burned on this recently and remember
vaguely it happening to me before. I've written some demonstration code
to
illustrate:

http://www.simplemessageboard.com/loopbug.cfm 

The solution as shown in the code is to set a local variable BEFORE
you
begin the inner loop to hold the value of the outer loop you want to
refer
to within the inner loop.

Anyone had this happen? Or is this expected behavior that I can't see?

BTW, this is CF5, I don't know about MX.


Tony Schreiber, Senior Partner  Man and Machine,
Limited
mailto:[EMAIL PROTECTED]  
http://www.technocraft.com 

http://www.is300.net The Enthusiast's Home of the Lexus IS300 since
1999
http://www.simplemessageboard.comFree Forum Software for Cold
Fusion


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Nested Query Loop Bug/Issue

2003-03-27 Thread David Collie (itndac)
On each loop, whatever values you want to use in your inner loops need
to be set to a local variable in the loop.
In fact, been burned so many times now I just dont bother using the loop
count and alwasy set the variables I need straight after my cfloop

ie

cfloop query=qSomething
cfset loop1Col1 = qSomething.MultiplyBy20 
cfset loop1Col2 = qSomething.MultiplyBy30 

cfloop from=1 to=100 index=tIndex
cfset output1 = loop1Col1 * tIndex
cfset output2 = loop1Col2 * tIndex
cfoutput#tIndex# - #output1#  - #output2#/cfoutput
/cfloop
/cfloop

Trying to access it as...
cfset output1 = qSomething.MultiplyBy20 * tIndex

Doesn't work (well, i didn't test the code but I hope you get my drift)

There is a tech support somewhere about this on the MM site but I can't
find much (no patience with it) any more and prefer looking elsewhere


This could be described as a FEATURE of cold fusionhehehehe



-Original Message-
From: Tony Schreiber [mailto:[EMAIL PROTECTED] 
Sent: 27 March 2003 17:04
To: CF-Talk
Subject: Nested Query Loop Bug/Issue


I don't know if any of you have run into this before or if it's even
been mentioned (couldn't find it at mm technotes either), but I've run
into a situation where the values of an outer loop referred to in an
inner loop are not what you expect. I was burned on this recently and
remember vaguely it happening to me before. I've written some
demonstration code to
illustrate:

http://www.simplemessageboard.com/loopbug.cfm

The solution as shown in the code is to set a local variable BEFORE you
begin the inner loop to hold the value of the outer loop you want to
refer to within the inner loop.

Anyone had this happen? Or is this expected behavior that I can't see?

BTW, this is CF5, I don't know about MX.


Tony Schreiber, Senior Partner  Man and Machine, Limited
mailto:[EMAIL PROTECTED]   http://www.technocraft.com

http://www.is300.net The Enthusiast's Home of the Lexus IS300 since 1999
http://www.simplemessageboard.comFree Forum Software for Cold Fusion


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Nested Query Loop Bug/Issue

2003-03-27 Thread Tony Schreiber
That's basically what the example variable in my demo code does - you
have to set it outside of the inner loop.

So is this a confirmed bug or anything?

 I have seen it before, not sure why it happens but what I did
 to solve it was set a temp variable to hold the first element of
 the query and reset it when it changes.

 cfset tempvar = ''
 cfoutput query=myQuery
  cfif tempvar NEQ myQuery.Value1
 cfset tempvar = myQuery.Value1
 /cfif
 
 ...


  [EMAIL PROTECTED] 03/27/03 12:04PM 
 I don't know if any of you have run into this before or if it's even
 been
 mentioned (couldn't find it at mm technotes either), but I've run into
 a
 situation where the values of an outer loop referred to in an inner
 loop
 are not what you expect. I was burned on this recently and remember
 vaguely it happening to me before. I've written some demonstration code
 to
 illustrate:

 http://www.simplemessageboard.com/loopbug.cfm

 The solution as shown in the code is to set a local variable BEFORE
 you
 begin the inner loop to hold the value of the outer loop you want to
 refer
 to within the inner loop.

 Anyone had this happen? Or is this expected behavior that I can't see?

 BTW, this is CF5, I don't know about MX.


 Tony Schreiber, Senior Partner  Man and Machine,
 Limited
 mailto:[EMAIL PROTECTED]
 http://www.technocraft.com

 http://www.is300.net The Enthusiast's Home of the Lexus IS300 since
 1999
 http://www.simplemessageboard.comFree Forum Software for Cold
 Fusion


 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Nested Query Loop Bug/Issue

2003-03-27 Thread James Ang
This issue has been around since v4.x. :P

The workaround mentioned is *the* workaround.

Confirmed bug or not? Not sure. Most developers just use the workaround.
:D

---
James Ang
Sr. Developer/Product Engineer
MedSeek, Inc.
[EMAIL PROTECTED]



-Original Message-
From: Tony Schreiber [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2003 9:18 AM
To: CF-Talk
Subject: Re: Nested Query Loop Bug/Issue


That's basically what the example variable in my demo code does - you
have to set it outside of the inner loop.

So is this a confirmed bug or anything?

 I have seen it before, not sure why it happens but what I did
 to solve it was set a temp variable to hold the first element of
 the query and reset it when it changes.

 cfset tempvar = ''
 cfoutput query=myQuery
  cfif tempvar NEQ myQuery.Value1
 cfset tempvar = myQuery.Value1
 /cfif
 
 ...


  [EMAIL PROTECTED] 03/27/03 12:04PM 
 I don't know if any of you have run into this before or if it's even
 been
 mentioned (couldn't find it at mm technotes either), but I've run into
 a
 situation where the values of an outer loop referred to in an inner
 loop
 are not what you expect. I was burned on this recently and remember
 vaguely it happening to me before. I've written some demonstration
code
 to
 illustrate:

 http://www.simplemessageboard.com/loopbug.cfm

 The solution as shown in the code is to set a local variable BEFORE
 you
 begin the inner loop to hold the value of the outer loop you want to
 refer
 to within the inner loop.

 Anyone had this happen? Or is this expected behavior that I can't see?

 BTW, this is CF5, I don't know about MX.


 Tony Schreiber, Senior Partner  Man and Machine,
 Limited
 mailto:[EMAIL PROTECTED]
 http://www.technocraft.com

 http://www.is300.net The Enthusiast's Home of the Lexus IS300 since
 1999
 http://www.simplemessageboard.comFree Forum Software for Cold
 Fusion


 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Nested Query Loop Bug/Issue

2003-03-27 Thread Dina Hess
Tony,

That's a known problem. To work around it, just set a local variable in the
outer loop equal to the value in Query1 you want to pass to Query2 and
access *that* variable inside of your inner loop.

~Dina

- Original Message -
From: Tony Schreiber [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Thursday, March 27, 2003 11:04 AM
Subject: Nested Query Loop Bug/Issue


 I don't know if any of you have run into this before or if it's even been
 mentioned (couldn't find it at mm technotes either), but I've run into a
 situation where the values of an outer loop referred to in an inner loop
 are not what you expect. I was burned on this recently and remember
 vaguely it happening to me before. I've written some demonstration code to
 illustrate:

 http://www.simplemessageboard.com/loopbug.cfm

 The solution as shown in the code is to set a local variable BEFORE you
 begin the inner loop to hold the value of the outer loop you want to refer
 to within the inner loop.

 Anyone had this happen? Or is this expected behavior that I can't see?

 BTW, this is CF5, I don't know about MX.


 Tony Schreiber, Senior Partner  Man and Machine, Limited
 mailto:[EMAIL PROTECTED]   http://www.technocraft.com

 http://www.is300.net The Enthusiast's Home of the Lexus IS300 since 1999
 http://www.simplemessageboard.comFree Forum Software for Cold Fusion

 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Nested Query Loop Bug/Issue

2003-03-27 Thread Tony Schreiber
Thanks Dina, I know the work-around (It's in my original message and
used in my demo code) - I guess I was looking for how many people had run
into this before and if it was an official known-issue or not, or even
expceted behavior...

 That's a known problem. To work around it, just set a local variable in the
 outer loop equal to the value in Query1 you want to pass to Query2 and
 access *that* variable inside of your inner loop.

 ~Dina

 - Original Message -
 From: Tony Schreiber [EMAIL PROTECTED]
 To: CF-Talk [EMAIL PROTECTED]
 Sent: Thursday, March 27, 2003 11:04 AM
 Subject: Nested Query Loop Bug/Issue


  I don't know if any of you have run into this before or if it's even been
  mentioned (couldn't find it at mm technotes either), but I've run into a
  situation where the values of an outer loop referred to in an inner loop
  are not what you expect. I was burned on this recently and remember
  vaguely it happening to me before. I've written some demonstration code to
  illustrate:
 
  http://www.simplemessageboard.com/loopbug.cfm
 
  The solution as shown in the code is to set a local variable BEFORE you
  begin the inner loop to hold the value of the outer loop you want to refer
  to within the inner loop.
 
  Anyone had this happen? Or is this expected behavior that I can't see?
 
  BTW, this is CF5, I don't know about MX.
 
 
  Tony Schreiber, Senior Partner  Man and Machine, Limited
  mailto:[EMAIL PROTECTED]   http://www.technocraft.com
 
  http://www.is300.net The Enthusiast's Home of the Lexus IS300 since 1999
  http://www.simplemessageboard.comFree Forum Software for Cold Fusion
 
 
 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Nested Query Loop Bug/Issue

2003-03-27 Thread Sicular, Alexander
i've had this problem before and arrived at the same solution as you. please fix this 
mm.

alex

 -Original Message-
 From: Tony Schreiber [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 27, 2003 12:04 PM
 To: CF-Talk
 Subject: Nested Query Loop Bug/Issue
 
 
 I don't know if any of you have run into this before or if 
 it's even been
 mentioned (couldn't find it at mm technotes either), but I've 
 run into a
 situation where the values of an outer loop referred to in an 
 inner loop
 are not what you expect. I was burned on this recently and remember
 vaguely it happening to me before. I've written some 
 demonstration code to
 illustrate:
 
 http://www.simplemessageboard.com/loopbug.cfm
 
 The solution as shown in the code is to set a local variable 
 BEFORE you
 begin the inner loop to hold the value of the outer loop you 
 want to refer
 to within the inner loop.
 
 Anyone had this happen? Or is this expected behavior that I can't see?
 
 BTW, this is CF5, I don't know about MX.
 
 
 Tony Schreiber, Senior Partner  Man and 
 Machine, Limited
 mailto:[EMAIL PROTECTED]   
 http://www.technocraft.com
 
 http://www.is300.net The Enthusiast's Home of the Lexus IS300 
 since 1999
 http://www.simplemessageboard.comFree Forum Software for 
 Cold Fusion
 
 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Nested Query Loop Bug/Issue

2003-03-27 Thread Philip Arnold
 I don't know if any of you have run into this before or if
 it's even been mentioned (couldn't find it at mm technotes
 either), but I've run into a situation where the values of an
 outer loop referred to in an inner loop are not what you
 expect. I was burned on this recently and remember vaguely it
 happening to me before. I've written some demonstration code to
 illustrate:

In fact, there are 3 work arounds, one is to set the field into a
variable, the second is to store the current row of the outer loop in a
variable, and then refer to the row of the query... The third is to not
loop over the query, but to loop over the record (with a CFLOOP INDEX
FROM TO)

Method 2:
CFLOOP QUERY=myQuery1
CFSET myQueryRow=CurrentRow
CFLOOP QUERY=myQuery2
CFIF myField2 eq myQuery1.myField[myQueryRow]
/CFIF
/CFLOOP
/CFLOOP

Method 3:
CFLOOP INDEX=i FROM=1 TO=#myQuery1.RecordCount#
CFLOOP QUERY=myQuery2
CFIF myField2 eq myQuery1.myField[i]
/CFIF
/CFLOOP
/CFLOOP


HTH


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4