This content has been marked as final. Show 5 replies
Have you thought about using a stored procedure? That would simplify some of your code and put it at the database level.
Please be more precise about the actual issue. Saying things like "I am having problems" is much too vague to be of any help. I have several scheduled tasks that run each day that take a long time to process and normally would just time out under the default time allowed to process a request. I am taking a wild guess that this may be your problem, and that your script may be simply stopping after the allotted time allowed to complete a request (check your admin settings - I think the default is 90 seconds)
Just curious - why are you setting session variables in a scheduled task? I'm not sure the CF scheduler supports cookies or session state. Are you trying to use those variables on another page?
Also, I second Mikeap's suggestion - a stored procedure will definitely help with your processing time and maintainability.
ok i changed the code to what i have below, this now sort of works, where the delete is i need it to delete the row of the current loop, the problem i get now is that
say there are 2 emails to loop over, they both get sent twice, so i think it is the delete query?
would it be this?
I believe it is getting sent out twice because your <cfmail> tag is inside a <cfloop> of your GetSchH1 query, but you also have your <cfmail> tag looping over the query (query="GetSchH1"). Remove the query="GetSchH1" from your <cfmail> tag and it should only send out 1 copy of each.
Also, I would perform your deletes outside of your loops - that way you only have to make 1 connection to the database to delete everything and you don't risk deleting the other records before you email them.