DFIDBDELUBUSOdDKUSERID 0 BEGIN DECLARE SECTION END DECLARE SECTION UPDATE LANM.CURRENT_EVENTS SET DELETE_FLAG = '1' WHERE DELETE_FLAG = '0' COMMIT UPDATE LANM.EVENT_LOG SET DELETE_FLAG= :hfch1 WHERE RESERVED = :hl1 SELECT COUNT(*) INTO :hlCurrEvents FROM LANM.CURRENT_EVENTS DECLARE delevents CURSOR WITH HOLD FOR SELECT RESERVED,SORT_NUM FROM LANM.EVENT_LOG WHERE DELETE_FLAG = :hfch1 ORDER BY SORT_NUM ASC OPEN delevents FETCH delevents into :hlReserved, :hl2 DELETE FROM LANM.EVENT_LOG WHERE RESERVED = :hlReserved DELETE FROM LANM.ALERT_DETAILS WHERE RESERVED = :hlReserved COMMIT CLOSE delevents DELETE FROM LANM.EVENT_LOG WHERE RESERVED = :hlReserved DELETE FROM LANM.ALERT_DETAILS WHERE RESERVED = :hlReserved COMMIT DELETE FROM LANM.BRIDGE_DEFINITIONS WHERE BRIDGE_NAME = :hach8_1 DELETE FROM LANM.BRIDGE_DEFINITIONS WHERE RESERVED = :hl1 SELECT ADAPT_ADDR, MONITORED_FLAG INTO :hach12_1, :hch1 FROM LANM.STATION_DEFINITION WHERE RESERVED = :hl1 DELETE FROM LANM.STATION_DEFINITION WHERE RESERVED = :hl1 COMMIT SELECT COUNT(*) INTO :hl1 FROM LANM.CONFIGURATION WHERE ADAPT_ADDR = :hach12_1 DELETE FROM LANM.LOCATION_DEF WHERE ADAPT_ADDR = :hach12_1 SELECT ADAPT_ADDR, MONITORED_FLAG INTO :hach12_1, :hch1 FROM LANM.STATION_DEFINITION WHERE ADAPT_NAME = :hach16_1 DELETE FROM LANM.STATION_DEFINITION WHERE ADAPT_NAME = :hach16_1 COMMIT SELECT SEGMENT_NO, RING_IN_ADDR, RING_OUT_ADDR, SECONDARY_ADDR INTO :hach3_1, :hach12_1, :hach12_2, :hach12_3 FROM LANM.CAU WHERE CAU_ID = :hach8_1 DELETE FROM LANM.CONFIGURATION WHERE (ADAPT_ADDR = :hach12_1 OR ADAPT_ADDR = :hach12_2 OR ADAPT_ADDR = :hach12_3) AND SEGMENT_NO = :hach3_1 DECLARE oncaus CURSOR WITH HOLD FOR SELECT ADAPT_ADDR FROM LANM.LOCATION_DEF WHERE CAU_ID = :hach8_1 FOR FETCH ONLY OPEN oncaus FETCH oncaus INTO :hach12_1 UPDATE LANM.CONFIGURATION SET CAU_ATTACHED_FLAG = '0' WHERE SEGMENT_NO = :hach3_1 AND ADAPT_ADDR = :hach12_1 FETCH oncaus INTO :hach12_1 CLOSE oncaus DELETE FROM LANM.CAU WHERE CAU_ID = :hach8_1 DELETE FROM LANM.CAU_LOBE_LOCATION WHERE CAU_ID = :hach8_1 DELETE FROM LANM.ALERT_FILTERS WHERE PRIORITY = :hch1 AND ALERT_ID = :hach8_1 AND RESOURCE_NAME = :hach8_2 AND ERROR_TYPE = :hch2 DECLARE performbridge CURSOR WITH HOLD FOR SELECT DISTINCT(BRIDGE_NAME) FROM LANM.BRIDGE_PERFORMANCE FOR FETCH ONLY OPEN performbridge FETCH performbridge into :h_bridgename SELECT MAX(SEQUENCE_NO) INTO :h_maxseq FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename SELECT MAX(LONG_SECONDS) INTO :h_maxtime FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename SELECT SEQUENCE_NO INTO :h_maxtime_seq FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename AND LONG_SECONDS = :h_maxtime DELETE FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename AND SEQUENCE_NO <= :h_num_recs COMMIT DELETE FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename AND SEQUENCE_NO > :h_maxtime_seq COMMIT UPDATE LANM.BRIDGE_PERFORMANCE SET SEQUENCE_NO = :h_new_seq WHERE BRIDGE_NAME = :h_bridgename AND SEQUENCE_NO = :h_i COMMIT DELETE FROM LANM.BRIDGE_PERFORMANCE WHERE BRIDGE_NAME = :h_bridgename AND SEQUENCE_NO BETWEEN (:h_maxtime_seq + 1) AND (:h_maxseq + :h_num_recs) COMMIT DECLARE reorderreports CURSOR WITH HOLD FOR SELECT SEQUENCE_NO, LONG_SECONDS FROM LANM.BRIDGE_PERFORMANCE ORDER BY LONG_SECONDS DESC OPEN reorderreports FETCH reorderreports INTO :h_i UPDATE LANM.BRIDGE_PERFORMANCE SET SEQUENCE_NO = :h_new_seq WHERE BRIDGE_NAME = :h_bridgename AND SEQUENCE_NO = :h_i COMMIT FETCH reorderreports INTO :h_i CLOSE reorderreports FETCH performbridge into :h_bridgename CLOSE performbridge COMMIT DELETE FROM LANM.CAU_QUALIFIERS WHERE SEGMENT = :hach3_1 DECLARE agedout CURSOR WITH HOLD FOR SELECT ADAPT_ADDR, SEGMENT_NO FROM LANM.CONFIGURATION WHERE :hl1 - ACTIVE_TIME > :hl2 OPEN agedout FETCH agedout INTO :hach12_1, :hach3_1 DELETE FROM LANM.PCNET_ATTACH_DATA WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.TR_ATTACH_DATA WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.PC_INFO WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.CONFIGURATION WHERE CURRENT OF AGEDOUT DELETE FROM LANM.LOCATION_DEF WHERE ADAPT_ADDR = :hach12_1 AND NOT EXISTS (SELECT * FROM LANM.STATION_DEFINITION SD WHERE SD.ADAPT_ADDR = :hach12_1) COMMIT CLOSE agedout DELETE FROM LANM.PCNET_ATTACH_DATA WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.TR_ATTACH_DATA WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.PC_INFO WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.CONFIGURATION WHERE ADAPT_ADDR = :hach12_1 AND SEGMENT_NO = :hach3_1 DELETE FROM LANM.LOCATION_DEF WHERE ADAPT_ADDR = :hach12_1 AND NOT EXISTS (SELECT * FROM LANM.STATION_DEFINITION SD WHERE SD.ADAPT_ADDR = :hach12_1) DELETE FROM LANM.EVENT_FILTERS WHERE RESERVED = :hl1 COMMIT hach3_1 hach8_1 hach8_2 hach10_1 hach12_1 hach12_2 hach12_3 hach16_1 hfch1 hlCurrEvents hlReserved h_bridgename h_maxseq h_maxtime h_maxtime_seq h_num_recs h_new_seq