Hello again,
 
Allright :-)
I have cached the results of a sql-Method via <dtml-let DATA=sqlListProjects>.
GroupID  ProjectID   Project
1               1                  "Gurr"
1               2                  "Muh"
2               3                  "Ih-Ah"
3               4                  "Mähh"
3               5                  "WauWau"
 
A second sqlMethod (sqlCount) returns:
Count
| 2 |
----
| 1 |
----
| 2 |
...
 
The two sql-Methods are related: Count shoes, how many Projects belong to one GroupID.
Now imagine that I want to print out the projects in the following way:
 
GroupID 1:
Gurr, Muh
 
GroupID 2:
Ih-Ah
 
GroupID 3:
Mäh, WauWau
 
To do that I have an outer iteration over sqlCount's results: In this case it would iterate 3 times. Within each iteration there's another iteration - and this 2nd one depends on the current row's Count (2 times in the 1st outer iteration, 1 time in the 2nd iteration etc.).
To print out the projects within the inner iteration I use the following technique:
 
<dtml-in "sqlCount(_.None,_)"> //outer iteration!
   <dtml-if sequence-start>
       <dtml-call "REQUEST.set('TEMP',1)">
   </dtml-if sequence-start>
 
   <dtml-call "REQUEST.set('TEMP2', (TEMP+_.getitem('Count'))-1)">
   <dtml-in DATA start=TEMP end=TEMP2> //inner iteration
            //Print ProjectIDs here
   </dtml-in>
   <dtml-call "REQUEST.set('TEMP', TEMP+(_.getitem('Count')))">
 
</dtml-in>
It may take some time to understand the code but it actually works as it should. I simply would prefer a cleaner solution where I would avoid the creation of different variables via REQUEST.set (which are then used in <dtml-in DATA start=VARIABLE)
but simply do the calculation within the "start=" and "end="
 
 
Was that still a bad description of my problem?
 
Thanks again,
Philipp Robbel