dcsimg

Deleting of a scheduled job results in Null Pointer error

Products

Webtrends Analytics 9.x
Webtrends Analytics 8.x

Issue

While trying to delete a scheduled job, you get a Null Pointer error.

Resolution

This script allows for thetargetedremoval of event entries without having to clear all the status logs. Do use this query, you will need to edit the SET@EventID line to match the EventID value of the job you want to delete.
DECLARE @EventID INT;
DECLARE @MonitorResultID INT;
DECLARE @TaskChronicleID INT;
/*change this line to the desired event ID to remove.*/
SET @EventID =XX;
DECLARE MonitorList
CURSOR FOR SELECT DISTINCT MonitorResultID
FROM wt_sched.dbo.WT_MonitorResult WHERE EventID = @EventID
OPEN MonitorList
FETCH NEXT FROM MonitorList INTO @MonitorResultID
WHILE @@FETCH_STATUS = 0
BEGIN
DELETE FROM wt_sched.dbo.WT_MonitorAlertResolveHistory WHERE MonitorResultID=@MonitorResultID;
DELETE FROM wt_sched.dbo.WT_MonitorResultAction WHERE MonitorResultID=@MonitorResultID;
FETCH NEXT FROM MonitorList INTO @MonitorResultID
END
CLOSE MonitorList
DEALLOCATE MonitorList
DECLARE TaskList
CURSOR FOR SELECT DISTINCT TaskChronicleID
FROM wt_sched.dbo.WT_TaskChronicle WHERE EventID = @EventID
OPEN TaskList
FETCH NEXT FROM TaskList INTO @TaskChronicleID
WHILE @@FETCH_STATUS = 0
BEGIN
DELETE FROM wt_sched.dbo.WT_TaskStatus WHERE TaskChronicleID = @TaskChronicleID;
FETCH NEXT FROM TaskList INTO @TaskChronicleID
END
CLOSE TaskList
DEALLOCATE TaskList
DELETE FROM wt_sched.dbo.WT_TaskChronicle WHERE EventID=@EventID;
DELETE FROM wt_sched.dbo.WT_EventStatus WHERE EventID=@EventID;
DELETE FROM wt_sched.dbo.WT_Schedule WHERE EventID=@EventID;
DELETE FROM wt_sched.dbo.WT_Parameter WHERE EventID=@EventID;
DELETE FROM wt_sched.dbo.WT_MonitorResult WHERE EventID=@EventID;
DELETE FROM wt_sched.dbo.WT_Event WHERE EventID=@EventID;
GO