• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFLOOP="query" in CFLOOP="query"

New Here ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

Hello all,

why does the example below does not work as it should? it always gives the the first record of the first loop. it does not remember the position of the first loop when in the second loop. What is the work around?

<CFLOOP query="qryReport">
<CFLOOP query="qryReportTitles">
#evaluate("qryReport." & qryReportTitles.feild & "_date")#


thanks for your help. this problem has been bugging me for years.



TOPICS
Advanced techniques

Views

408

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 08, 2006 Jun 08, 2006
It dosen't seem to be that complicated. Coldfusion does not loose track of the current row of the outside query loop. It is a scoping issue and you cannot reference the outer query loop in the same way. The code will work just fine if you append ([report.currentRow]) to the evaluate statement in the inner loop like this:

Votes

Translate

Translate
New Here ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

For some reason, ColdFusion loses track of the query current row on the outside loop when you have an inside loop. To solve this, we wrote a custom tag, which we call duplicate_row, that creates a query with exactly one row, the current row of the outside loop. Then we use the new one row query in the inside loop. This works well, and the overhead is not tremendous.

I've attached the source for the custom tag.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

It dosen't seem to be that complicated. Coldfusion does not loose track of the current row of the outside query loop. It is a scoping issue and you cannot reference the outer query loop in the same way. The code will work just fine if you append ([report.currentRow]) to the evaluate statement in the inner loop like this:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

LATEST
hey jmmorgan, thanks a lot. the only thing that i had to do was to use.
"_date[report.currentRow]"

i'm such a better programmer now.

this was very easy to implement since i did not want to construct a query.

also thanks for your help mike


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation