Subject | Re: Daily triggers |
---|---|
Author | homerjones1941 |
Post date | 2011-03-17T18:16:43Z |
> If the procedure should run maximum once per day, add a table that contains only one record with a field like DateLastRun and then start your procedure by checking the current value of this field and update it if it is less than today, quit your procedure otherwise. <This mirrors my plan with only one exception. The procedure checks the Last Run Date and then it does something like: If Current_Date > LastRunDate then do the stuff... (Psuedo Code, obviously). This prevents a second execution because I update the last run field at the beginning of the procedure. If the procedure fails, then it resets the date back to its original. This seems to work even thought my testing has been somewhat limited.
BTW, it does not harm anything to be run multiple times. Like you say, it just wastes resources.
As a side note, this same procedure was implemented in an earlier version of my app, using MS Access (client side). It was so slow that I had to display a warning about how long it could take. With a Firebird Stored Procedure, the whole process takes 200 to 300 ms (the blink of an eye) on an old Pentium 1.73 Ghz with 2 gigs RAM. So, even if the process is run twice, there will be little wasted ressources.
I'm not sure if I want to do this because it's what should be done, or because I'm new to Firebird, and want to learn as much as I can.
Thanks to everyone for all your help.
> You can never control your users 100%.Amen.