This is because you always access the first record from the outer loop
in the inner loop. Solution in your code below!

-----Original Message-----
From: Angel Stewart [mailto:[EMAIL PROTECTED]]
Sent: maandag 21 januari 2002 16:02
To: CF-Talk
Subject: Problems with looping


Hey all! 

Take a look at this code.

The idea of course, is to loop through all the employees in the table
and run a particular query against each employee.

_______________________________________________________

<CFQUERY name="GetEmployees" datasource="xxxxx" DBTYPE="ORacle80">

        Select Employee_ID FROM Empl_General
                
</CFQUERY>      

<CFOUTPUT query="GetEmployees">

<CFSET i = GetEmployees.currentRow> !!!!!!!!!!!!

        <CFLOOP CONDITION="#CurrentDate# LESS THAN OR EQUAL TO
#EndDate#">
                <CFSET CurrentDate=
DateFormat(#CurrentDate#,'mm/dd/yyyy')> 

                <CFQUERY name="GetHours" datasource="xxxx"
DBTYPE="Oracle80">
                        
                        Select SUM(RegHrs) AS TotalHours FROM
TblMainEntry,TblDetailEntry
                                        WHERE TblMainEntry.EmpID=
#GetEmployees.Employee_ID[i]# !!!!!!!!!!!!!!!!!!!!!!!!!!
                                                        AND tblDetailEntry.RecordDate=
to_date('#currentdate#','mm/dd/yyyy')
                
                        AND tblMainEntry.MainID = TblDetailEntry.MainID
                
                </CFQUERY>
        
        <CFIF GetHours.TotalHours GT 24>

                #GetHours.Employee_ID# &nbsp&nbsp #GetHours.TotalHours#
        
        </CFIF>
        
        <CFSET CurrentDate = DateAdd("d",CurrentDate,1)>

        </CFLOOP>
        
</CFOUTPUT>

_______________________________________________-

However, it picks up the first employee, runs through the SQL statements
etc. and then never goes onto the second.

Any idea why this is happening? 

I must be missing something really simple, but I can't figure out what.

-Angel



______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to