ResultID ProcessName StartTime EndTime Succeeded -------- ----------- --------- ------- --------- 0 BuildWidgets 7:20 PM 7:25 PM True 1 BuildWidgets 7:20 PM 7:28 PM False 2 BuildWidgets 3:50 PM 3:55 PM True 3 BuildSprockets 4:20 PM 5:25 PM True 4 BuildWidgets 9:50 PM NULL NULL 5 BuildSprockets 9:30 PM NULL NULLI want to have a stored procedure update this table every few minutes and sets Succeeded = false for all the records where it's taken longer than any prior succeeded instance of that ProcessName. In this example, when BuildWidgets passes, it always takes at most 5 minutes, whereas BuildSprockets might take an hour. For example, at 10:00 PM, we'd update the ResultID 4 BuildWidgets Passed = False, but leave the ResultID 5 BuildSprockets row alone since it might still be running.
create view process_with_hueristic_applied as
select
a.*,
case when datediff( ss, a.starttime, getdate() )
> ( select max( datediff( ss, b.starttime, b.endtime ) )
from processes b
where b.processname = a.processname and b.endtime is not null)
then 1 else 0 end as probably_dead
from processes a;
You are not logged in, either login or create an account to post comments
posted by 0xFCAF at 12:55 PM on July 26, 2009