I'm no SQL guru, but seems like you could do another table join and
sweep
all this information in one query. The condition for which you are
looping
over could probably be made into part of the main WHERE clause. That
would
make the code cleaner and much faster. That's my take on it ;)
EC
-----Original Message-----
From: Angel Stewart [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 10:02 AM
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">
<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#
AND tblDetailEntry.RecordDate=
to_date('#currentdate#','mm/dd/yyyy')
AND tblMainEntry.MainID = TblDetailEntry.MainID
</CFQUERY>
<CFIF GetHours.TotalHours GT 24>
#GetHours.Employee_ID#    #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
______________________________________________________________________
Why Share?
Dedicated Win 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=coldfusionc
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