Cisco Transport Manager データベース スキーマ Release 6.0
パッケージ、プロシージャ、関数、 およびトリガー
パッケージ、プロシージャ、関数、およびトリガー
発行日;2012/01/07 | ドキュメントご利用ガイド | ダウンロード ; この章pdf , ドキュメント全体pdf (PDF - 7MB) | フィードバック

目次

パッケージ、プロシージャ、関数、およびトリガー

パッケージ、プロシージャ、関数、およびトリガー

この章では、CTM テーブルで定義されているストアド パッケージ、プロシージャ、関数、およびトリガーの内容を示します。

3.1 CTM パッケージ

この項では、CTM テーブルで定義されているパッケージの内容を示します。パッケージはアルファベット順に示されています。

3.1.1 CTMAlarm

Create or Replace package CTMAlarm is
 
--TYPE link_id_tabtype is Table of number INDEX by BINARY_INTEGER;
 
INVALID_ALARM_STATUS EXCEPTION;
PRAGMA EXCEPTION_INIT (INVALID_ALARM_STATUS, -20002);
 
ALARM_NOT_FOUND EXCEPTION;
PRAGMA EXCEPTION_INIT (ALARM_NOT_FOUND, -20000);
 
Procedure alarm_handle_impl
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure clear_alarms_impl
(p_nedbaccessid IN number,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_clearalarmtimestamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure add_clear_alarms_impl
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure alarm_handle
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure clear_alarms
(p_nedbaccessid IN number,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_clearalarmtimestamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure add_clear_alarms
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
);
 
Procedure bulk_alarm_handle
(
p_AlarmInfoList IN AlarmInfoListType
);
 
Procedure bulk_clear_alarms
(
p_AlarmInfoList IN AlarmInfoListType
);
 
Procedure bulk_add_clear_alarms
(
p_AlarmInfoList IN AlarmInfoListType
);
 
END CTMAlarm;
/
create or replace package body CTMAlarm is
 
Procedure alarm_handle_impl
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2)
IS
--INVALID_ALARM_STATUS EXCEPTION;
--PRAGMA EXCEPTION_INIT (INVALID_ALARM_STATUS, -20002);
counter number:=0;
total_num_linkid number:=0;
BEGIN
 
IF (p_alarmstatus = 0) THEN
-- this is the new alarm
begin
INSERT INTO active_alarm_table (
NEDBACCESSID,
ALARMSEQNUM,
MODULEORIFINDEX,
ACTIVEALARMTIMESTAMP,
ACTIVEALARMTYPE,
ACTIVEALARMSEVERITY,
ACTIVEALARMSERVEFF,
ACTIVEALARMADDITIONALINFO,
ACKINDEX,
ACTIVEALARMFLAG,
NEALARMTIMESTAMP,
ACTIVEALARMINDEX,
MODULETYPE,
PHYSICALLOC,
ALARMSTATUS,
EXTERNALCONDITION,
MODELTYPE,
OBJECTTYPE,
STROBJINSTANCE)
Values (
p_nedbaccessid,
p_alarmseqnum,
p_moduleorifindex,
p_activealarmtimestamp,
p_activealarmtype,
p_activealarmseverity,
p_activealarmserveff,
p_activealarmadditionalinfo,
p_ackindex,
p_activealarmflag,
p_nealarmtimestamp,
activealarmindex_seq.nextval,
p_moduletype,
p_physicalloc,
p_alarmstatus,
p_externalcondition,
p_ModelType,
p_ObjectType,
p_StrObjInstance);
exception
when DUP_VAL_ON_INDEX then
dbms_output.put_line('Duplicate alarm');
create_file('/tmp','alarm_handling.log','Duplicated alarms');
 
select count(*) into counter from active_alarm_table
where nedbaccessid=p_nedbaccessid
AND moduleorifindex=p_ModuleOrIfIndex
AND ActiveAlarmType=p_ActiveAlarmType
AND NEAlarmTimeStamp=p_NEAlarmTimeStamp
AND Physicalloc=p_Physicalloc
AND ObjectType = p_ObjectType
AND alarmstatus=0;
UPDATE active_alarm_table
SET activealarmflag=0,
alarmstatus=0,
clearalarmtimestamp=to_date(''),
nealarmcleartimestamp=to_date(''),
ActiveAlarmSeverity=p_ActiveAlarmSeverity,
ActiveAlarmServEff=p_ActiveAlarmServEff,
ActiveAlarmAdditionalInfo=p_ActiveAlarmAdditionalInfo,
ModuleType=p_ModuleType
WHERE nedbaccessid=p_nedbaccessid
AND moduleorifindex=p_ModuleOrIfIndex
AND ActiveAlarmType=p_ActiveAlarmType
AND NEAlarmTimeStamp=p_NEAlarmTimeStamp
AND Physicalloc=p_Physicalloc
AND ObjectType = p_ObjectType
AND ModelType = p_ModelType
AND StrObjInstance = p_StrObjInstance;
--commit;
IF ( counter = 1) THEN
return;
END IF;
--commit;
end;
 
total_num_linkid := p_linkid.count;
FOR table_row IN 1 .. total_num_linkid LOOP
--dbms_output.put_line('p_linkid=' || p_linkid(table_row));
IF (p_linkid(table_row) != -1) THEN
IF (p_activealarmseverity = 4) THEN
UPDATE link_table
SET NumWarningAlarms=NumWarningAlarms+1
WHERE linkid=p_linkid(table_row);
--commit;
END IF;
 
IF (p_activealarmseverity = 5) Then
UPDATE link_table
SET NumMinorAlarms=NumMinorAlarms+1
WHERE linkid = p_linkid(table_row);
--commit;
END IF;
 
IF (p_activealarmseverity = 6) THEN
UPDATE link_table
SET NumMajorAlarms=NumMajorAlarms+1
WHERE linkid = p_linkid(table_row);
--commit;
END IF;
 
IF (p_activealarmseverity = 7) THEN
UPDATE link_table
SET NumCriticalAlarms=NumCriticalAlarms+1
WHERE linkid= p_linkid(table_row);
--commit;
END IF;
END IF;
END LOOP;
ELSE
raise INVALID_ALARM_STATUS;
END IF;
 
END;
 
Procedure clear_alarms_impl
(p_nedbaccessid IN number,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_clearalarmtimestamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2)
IS
rows_processed number :=0;
cursor_handle INTEGER;
statement_txt varchar2(4000):= null;
total_num_linkid number:=0;
 
--ALARM_NOT_FOUND EXCEPTION;
--PRAGMA EXCEPTION_INIT (ALARM_NOT_FOUND, -20000);
--INVALID_ALARM_STATUS EXCEPTION;
--PRAGMA EXCEPTION_INIT (INVALID_ALARM_STATUS, -20002);
BEGIN
---- alarm resync
IF (p_alarmstatus = 1 ) THEN
IF (p_actiontype=1) THEN
cursor_handle := DBMS_SQL.OPEN_CURSOR;
dbms_output.put_line(p_nedbaccessid);
 
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), activealarmflag=0, NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')';
statement_txt := statement_txt||' Where alarmstatus=0 AND activealarmflag =1 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
-- statement_txt := statement_txt||' and activealarmseverity='||p_activealarmseverity;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
 
--dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
IF (p_actiontype=2) THEN
-- this when in service ne put out of service, keep the activealarmflag=2
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), activealarmflag =2, NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')';
statement_txt := statement_txt||' Where alarmstatus=0 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
 
------ Normal clear alarms
IF (p_actiontype = 0) THEN
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')' ;
statement_txt := statement_txt||' Where alarmstatus=0 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
-- statement_txt := statement_txt||' and activealarmseverity='||p_activealarmseverity;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
-- dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
 
total_num_linkid := p_linkid.count;
FOR table_row IN 1 .. total_num_linkid LOOP
IF (p_linkid(table_row) != -1) THEN
IF (p_activealarmseverity = 4) THEN
UPDATE link_table
SET NumWarningAlarms=NumWarningAlarms-1
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 5) Then
UPDATE link_table
SET NumMinorAlarms=NumMinorAlarms-1
WHERE linkid = p_linkid(table_row)
AND NumMinorAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 6) THEN
UPDATE link_table
SET NumMajorAlarms=NumMajorAlarms-1
WHERE linkid = p_linkid(table_row)
AND NumMajorAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 7) THEN
UPDATE link_table
SET NumCriticalAlarms=NumCriticalAlarms-1
WHERE linkid= p_linkid(table_row)
AND NumCriticalAlarms > 0;
--commit;
END IF;
 
END IF;
END LOOP;
ELSE
raise INVALID_ALARM_STATUS;
END IF;
END;
 
Procedure add_clear_alarms_impl
(p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2)
IS
rows_processed number :=0;
cursor_handle INTEGER;
statement_txt varchar2(4000):= null;
total_num_linkid number:=0;
 
--ALARM_NOT_FOUND EXCEPTION;
--PRAGMA EXCEPTION_INIT (ALARM_NOT_FOUND, -20000);
--INVALID_ALARM_STATUS EXCEPTION;
--PRAGMA EXCEPTION_INIT (INVALID_ALARM_STATUS, -20002);
BEGIN
---- alarm resync
IF (p_alarmstatus = 1 ) THEN
IF (p_actiontype=1) THEN
cursor_handle := DBMS_SQL.OPEN_CURSOR;
dbms_output.put_line(p_nedbaccessid);
 
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), activealarmflag=0, NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')';
statement_txt := statement_txt||' Where alarmstatus=0 AND activealarmflag =1 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
-- statement_txt := statement_txt||' and activealarmseverity='||p_activealarmseverity;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
 
dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
 
IF (p_actiontype=2) THEN
-- this when in service ne put out of service, keep the activealarmflag=2
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), activealarmflag =2, NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')';
statement_txt := statement_txt||' Where alarmstatus=0 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
 
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
 
------ Normal clear alarms
IF (p_actiontype = 0) THEN
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt:='Update active_alarm_table set alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||'), NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||')' ;
statement_txt := statement_txt||' Where alarmstatus=0 AND nedbaccessid= '||p_nedbaccessid ;
statement_txt := statement_txt||' and moduleorifindex='||p_moduleorifindex;
statement_txt := statement_txt||' and activealarmtype='||p_activealarmtype;
-- statement_txt := statement_txt||' and activealarmseverity='||p_activealarmseverity;
statement_txt := statement_txt||' and physicalloc='||p_physicalloc;
statement_txt := statement_txt||' and modeltype='||p_ModelType;
statement_txt := statement_txt||' and objecttype='||p_ObjectType;
statement_txt := statement_txt||' and strobjinstance='||''''||p_StrObjInstance||'''';
-- dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
--commit;
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
raise ALARM_NOT_FOUND;
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
total_num_linkid := p_linkid.count;
FOR table_row IN 1 .. total_num_linkid LOOP
IF (p_linkid(table_row) != -1) THEN
IF (p_activealarmseverity = 4) THEN
UPDATE link_table
SET NumWarningAlarms=NumWarningAlarms-1
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 5) Then
UPDATE link_table
SET NumMinorAlarms=NumMinorAlarms-1
WHERE linkid = p_linkid(table_row)
AND NumMinorAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 6) THEN
UPDATE link_table
SET NumMajorAlarms=NumMajorAlarms-1
WHERE linkid = p_linkid(table_row)
AND NumMajorAlarms > 0;
--commit;
END IF;
 
IF (p_activealarmseverity = 7) THEN
UPDATE link_table
SET NumCriticalAlarms=NumCriticalAlarms-1
WHERE linkid= p_linkid(table_row)
AND NumCriticalAlarms > 0;
--commit;
END IF;
 
END IF;
END LOOP;
ELSE
raise INVALID_ALARM_STATUS;
END IF;
EXCEPTION
when ALARM_NOT_FOUND then
dbms_output.put_line('New insertion of cleared alarm');
IF (p_actiontype = 1 OR p_actiontype = 2) THEN
INSERT INTO active_alarm_table (
NEDBACCESSID,
ALARMSEQNUM,
MODULEORIFINDEX,
ACTIVEALARMTIMESTAMP,
ACTIVEALARMTYPE,
ACTIVEALARMSEVERITY,
ACTIVEALARMSERVEFF,
ACTIVEALARMADDITIONALINFO,
ACKINDEX,
ACTIVEALARMFLAG,
CLEARALARMTIMESTAMP,
NEALARMTIMESTAMP,
NEALARMCLEARTIMESTAMP,
ACTIVEALARMINDEX,
MODULETYPE,
PHYSICALLOC,
ALARMSTATUS,
EXTERNALCONDITION,
MODELTYPE,
OBJECTTYPE,
STROBJINSTANCE)
Values (
p_nedbaccessid,
p_alarmseqnum,
p_moduleorifindex,
p_activealarmtimestamp,
p_activealarmtype,
p_activealarmseverity,
p_activealarmserveff,
p_activealarmadditionalinfo,
p_ackindex,
p_activealarmflag,
p_clearalarmtimestamp,
p_nealarmtimestamp,
p_nealarmcleartimestamp,
activealarmindex_seq.nextval,
p_moduletype,
p_physicalloc,
p_alarmstatus,
p_externalcondition,
p_ModelType,
p_ObjectType,
p_StrObjInstance);
--commit;
END IF;
 
END;
 
Procedure alarm_handle
(
p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
)
IS
BEGIN
--dbms_output.put_line('alarm_handle: calling alarm_handle_impl: nedbaccessid=' || p_nedbaccessid || ', ActiveAlarmComment=' || p_ActiveAlarmComment || ', alarmstatus=' || p_alarmstatus);
 
alarm_handle_impl
(
p_nedbaccessid,
p_Alarmseqnum,
p_ModuleOrIfIndex,
p_ActiveAlarmTimeStamp,
p_ActiveAlarmType,
p_ActiveAlarmSeverity,
p_ActiveAlarmServEff,
p_ActiveAlarmAdditionalInfo,
p_AckIndex,
p_ActiveAlarmFlag,
p_ActiveAlarmComment,
p_NEAlarmTimeStamp,
p_ModuleType,
p_Physicalloc,
p_alarmstatus,
p_linkid,
p_actiontype,
p_externalcondition,
p_ModelType,
p_ObjectType,
p_StrObjInstance
);
 
commit;
 
END;
 
Procedure clear_alarms
(
p_nedbaccessid IN number,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_clearalarmtimestamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN varchar2
)
IS
BEGIN
--dbms_output.put_line('clear_alarms: calling clear_alarms_impl: nedbaccessid=' || p_nedbaccessid || ', alarmstatus=' || p_alarmstatus);
 
clear_alarms_impl
(
p_nedbaccessid,
p_ModuleOrIfIndex,
p_ActiveAlarmType,
p_ActiveAlarmSeverity,
p_clearalarmtimestamp,
p_NEAlarmClearTimeStamp,
p_Physicalloc,
p_alarmstatus,
p_linkid,
p_actiontype,
p_ModelType,
p_ObjectType,
p_StrObjInstance
);
 
commit;
END;
 
Procedure add_clear_alarms
(
p_nedbaccessid IN number,
p_Alarmseqnum IN number default 0,
p_ModuleOrIfIndex IN number,
p_ActiveAlarmTimeStamp IN date,
p_ActiveAlarmType IN number,
p_ActiveAlarmSeverity IN number,
p_ActiveAlarmServEff IN number,
p_ActiveAlarmAdditionalInfo IN varchar2,
p_AckIndex IN number,
p_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_ModuleType IN number,
p_Physicalloc IN number,
p_alarmstatus IN number,
p_linkid IN link_id_tabtype,
p_actiontype IN number,
p_externalcondition IN varchar2,
p_ModelType IN number,
p_ObjectType IN number,
p_StrObjInstance IN VARCHAR2
)
IS
BEGIN
--dbms_output.put_line('add_clear_alarms: calling add_clear_alarms_impl: nedbaccessid=' || p_nedbaccessid || ', alarmstatus=' || p_alarmstatus);
 
add_clear_alarms_impl
(
p_nedbaccessid,
p_Alarmseqnum,
p_ModuleOrIfIndex,
p_ActiveAlarmTimeStamp,
p_ActiveAlarmType,
p_ActiveAlarmSeverity,
p_ActiveAlarmServEff,
p_ActiveAlarmAdditionalInfo,
p_AckIndex,
p_ActiveAlarmFlag,
p_ClearAlarmTimeStamp,
p_NEAlarmTimeStamp,
p_NEAlarmClearTimeStamp,
p_ModuleType,
p_Physicalloc,
p_alarmstatus,
p_linkid,
p_actiontype,
p_externalcondition,
p_ModelType,
p_ObjectType,
p_StrObjInstance
);
 
commit;
END;
 
Procedure bulk_alarm_handle
(
p_AlarmInfoList IN AlarmInfoListType
)
IS
i number;
BEGIN
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
LOOP
--dbms_output.put_line('bulk_alarm_handle: calling alarm_handle_impl: i=' || i || ':, nedbaccessid=' || p_AlarmInfoList(i).nedbaccessid || ', ActiveAlarmComment=' || p_AlarmInfoList(i).ActiveAlarmComment || ', alarmstatus=' || p_AlarmInfoList(i).alarmstatus);
 
alarm_handle_impl (
p_AlarmInfoList(i).nedbaccessid,
p_AlarmInfoList(i).Alarmseqnum,
p_AlarmInfoList(i).ModuleOrIfIndex,
p_AlarmInfoList(i).ActiveAlarmTimeStamp,
p_AlarmInfoList(i).ActiveAlarmType,
p_AlarmInfoList(i).ActiveAlarmSeverity,
p_AlarmInfoList(i).ActiveAlarmServEff,
p_AlarmInfoList(i).ActiveAlarmAdditionalInfo,
p_AlarmInfoList(i).AckIndex,
p_AlarmInfoList(i).ActiveAlarmFlag,
p_AlarmInfoList(i).ActiveAlarmComment,
p_AlarmInfoList(i).NEAlarmTimeStamp,
p_AlarmInfoList(i).ModuleType,
p_AlarmInfoList(i).Physicalloc,
p_AlarmInfoList(i).alarmstatus,
p_AlarmInfoList(i).linkid,
p_AlarmInfoList(i).actiontype,
p_AlarmInfoList(i).externalcondition,
p_AlarmInfoList(i).ModelType,
p_AlarmInfoList(i).ObjectType,
p_AlarmInfoList(i).StrObjInstance
);
 
END LOOP;
 
commit;
END;
 
Procedure bulk_clear_alarms
(
p_AlarmInfoList IN AlarmInfoListType
)
IS
i number;
BEGIN
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
LOOP
dbms_output.put_line('bulk_clear_alarms: calling clear_alarms_impl: i=' || i || ':, nedbaccessid=' || p_AlarmInfoList(i).nedbaccessid || ', ActiveAlarmComment=' || p_AlarmInfoList(i).ActiveAlarmComment || ', alarmstatus=' || p_AlarmInfoList(i).alarmstatus);
 
clear_alarms_impl
(
p_AlarmInfoList(i).nedbaccessid,
p_AlarmInfoList(i).ModuleOrIfIndex,
p_AlarmInfoList(i).ActiveAlarmType,
p_AlarmInfoList(i).ActiveAlarmSeverity,
p_AlarmInfoList(i).clearalarmtimestamp,
p_AlarmInfoList(i).NEAlarmClearTimeStamp,
p_AlarmInfoList(i).Physicalloc,
p_AlarmInfoList(i).alarmstatus,
p_AlarmInfoList(i).linkid,
p_AlarmInfoList(i).actiontype,
p_AlarmInfoList(i).ModelType,
p_AlarmInfoList(i).ObjectType,
p_AlarmInfoList(i).StrObjInstance
);
 
END LOOP;
 
commit;
END;
 
Procedure bulk_add_clear_alarms
(
p_AlarmInfoList IN AlarmInfoListType
)
IS
i number;
BEGIN
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
LOOP
--dbms_output.put_line('bulk_add_clear_alarms: calling add_clear_alarms_impl: i=' || i || ':, nedbaccessid=' || p_AlarmInfoList(i).nedbaccessid || ', ActiveAlarmComment=' || p_AlarmInfoList(i).ActiveAlarmComment || ', alarmstatus=' || p_AlarmInfoList(i).alarmstatus);
 
add_clear_alarms_impl
(
p_AlarmInfoList(i).nedbaccessid,
p_AlarmInfoList(i).Alarmseqnum,
p_AlarmInfoList(i).ModuleOrIfIndex,
p_AlarmInfoList(i).ActiveAlarmTimeStamp,
p_AlarmInfoList(i).ActiveAlarmType,
p_AlarmInfoList(i).ActiveAlarmSeverity,
p_AlarmInfoList(i).ActiveAlarmServEff,
p_AlarmInfoList(i).ActiveAlarmAdditionalInfo,
p_AlarmInfoList(i).AckIndex,
p_AlarmInfoList(i).ActiveAlarmFlag,
p_AlarmInfoList(i).ClearAlarmTimeStamp,
p_AlarmInfoList(i).NEAlarmTimeStamp,
p_AlarmInfoList(i).NEAlarmClearTimeStamp,
p_AlarmInfoList(i).ModuleType,
p_AlarmInfoList(i).Physicalloc,
p_AlarmInfoList(i).alarmstatus,
p_AlarmInfoList(i).linkid,
p_AlarmInfoList(i).actiontype,
p_AlarmInfoList(i).externalcondition,
p_AlarmInfoList(i).ModelType,
p_AlarmInfoList(i).ObjectType,
p_AlarmInfoList(i).StrObjInstance
);
 
END LOOP;
 
commit;
 
END;
 
END CTMAlarm;
/

3.1.2 MSMCircuit

--CIRCUIT_BS_TBL
create TYPE circuit_bs_tbl_struct as OBJECT (
CKTNODEID NUMBER,
CKTUNIQUEID NUMBER,
CKTNAME VARCHAR2 (64),
CKTDESCRIPTION VARCHAR2 (256),
CUSTOMERID VARCHAR2 (256),
SERVICEID VARCHAR2 (256),
CKTTYPE NUMBER,
CKTSIZE NUMBER,
CKTDIRECTION NUMBER,
CKTISMONITOR NUMBER,
CKTSTATE NUMBER,
CKTENHANCEDSTATE NUMBER,
CKTPROTECTIONTYPE NUMBER,
CKTADDITIONALINFO VARCHAR2(64),
CKTCOMMENT VARCHAR2 (2014),
CKTUSElAP NUMBER,
CKTOCHNCCHANNEL NUMBER,
CKTOCHNCDIR NUMBER,
ISDUPLICATENAME NUMBER,
NPID NUMBER
);
/
 
create TYPE circuit_bs_tbl_struct_list as table of circuit_bs_tbl_struct;
/
 
create TYPE circuit_identity_struct as OBJECT (
CKTNODEID NUMBER,
CKTUNIQUEID NUMBER
);
/
 
create TYPE circuit_identity_struct_list as table of circuit_identity_struct;
/
 
--CIRCUIT_CTP_TBL
create TYPE circuit_ctp_tbl_struct as OBJECT (
CTP_TYPE NUMBER,
CKTNODEID NUMBER,
CKTUNIQUEID NUMBER,
CTPNODEID NUMBER,
CTPMODULETYPE NUMBER,
CTPIFINDEX NUMBER,
CTPOBJECTINDEX NUMBER,
CTPPHYSICALLOC NUMBER,
CKTMODELTYPE NUMBER,
CTPDROPPROT NUMBER,
CKTCTPPATHPROT NUMBER,
CTPDROPPROTTYPE NUMBER,
CTPPORTNAME VARCHAR2 (64),
CTPADDITIONALINFO VARCHAR2 (64)
);
/
 
create TYPE circuit_ctp_tbl_struct_list as table of circuit_ctp_tbl_struct;
/
 
--CIRCUIT_SPAN_BS_TBL
create TYPE circuit_span_bs_tbl_struct as OBJECT (
CKTNODEID NUMBER,
CKTUNIQUEID NUMBER,
CKTLINKID NUMBER,
SPAN_TYPE NUMBER,
SRC_CTP_TYPE NUMBER,
SRC_CTPNODEID NUMBER,
SRC_CTPMODULETYPE NUMBER,
SRC_CTPIFINDEX NUMBER,
SRC_CTPOBJECTINDEX NUMBER,
SRC_CTPPHYSICALLOC NUMBER,
SRC_CKTMODELTYPE NUMBER,
DST_CTP_TYPE NUMBER,
DST_CTPNODEID NUMBER,
DST_CTPMODULETYPE NUMBER,
DST_CTPIFINDEX NUMBER,
DST_CTPOBJECTINDEX NUMBER,
DST_CTPPHYSICALLOC NUMBER,
DST_CKTMODELTYPE NUMBER,
CKTSPANSRCSTATE NUMBER,
CKTSPANDESTSTATE NUMBER,
ISCKTFORWARDING NUMBER,
SCKTSPANINUPSR NUMBER,
ISCKTSPANWORKING NUMBER,
ISCKTSPANACTIVE NUMBER,
CKTSPANPROTOP NUMBER,
CKTSPANCDLFLOWID NUMBER,
CKTSPANSRCPORTNAME VARCHAR2(64),
CKTSPANDESTPORTNAME VARCHAR2(64)
);
/
 
create TYPE circuit_span_bs_tbl_st_list as table of circuit_span_bs_tbl_struct;
/
 
Create or Replace package MSMCircuit is
 
Procedure create_circuit
(
circuit_bs_tbl_data IN circuit_bs_tbl_struct_list,
circuit_ctp_tbl_data IN circuit_ctp_tbl_struct_list,
circuit_span_bs_tbl_data IN circuit_span_bs_tbl_st_list
);
 
Procedure update_circuit
(
circuit_bs_tbl_data IN circuit_bs_tbl_struct_list,
circuit_ctp_tbl_data IN circuit_ctp_tbl_struct_list,
circuit_span_bs_tbl_data IN circuit_span_bs_tbl_st_list
);
 
Procedure update_circuit_ctps
(
p_nedbaccessid IN NUMBER,
p_ckt_min_physicalloc IN NUMBER,
p_ckt_max_physicalloc IN NUMBER,
p_cktmoduletype IN NUMBER,
cktmoduletype_upd_flag IN NUMBER,
p_cktportname IN VARCHAR2,
cktportname_udp_flag IN NUMBER
);
 
Procedure delete_circuit
(
circuit_id_list IN circuit_identity_struct_list,
delcomp IN NUMBER
);
 
Procedure delete_circuits_on_nodeList
(
circuit_id_list IN circuit_identity_struct_list
);
 
END MSMCircuit;
/
 
create or Replace package body MSMCircuit is
 
Procedure create_circuit
(
circuit_bs_tbl_data IN circuit_bs_tbl_struct_list,
circuit_ctp_tbl_data IN circuit_ctp_tbl_struct_list,
circuit_span_bs_tbl_data IN circuit_span_bs_tbl_st_list
)
IS
p_npid NUMBER(1);
i number;
create_circuit_failed EXCEPTION;
i_CTPACCESSID NUMBER;
i_CKTSPANBSID NUMBER;
i_CKTSPANSRCCTPACCESSID NUMBER;
i_CKTSPANDSTCTPACCESSID NUMBER;
p_CKTCTPNeDBAccessId NUMBER;
BEGIN
i := circuit_bs_tbl_data.FIRST;
p_npid := circuit_bs_tbl_data(i).NPID;
-- BEGIN
-- Get NPID. It is not sent by application.
-- select sub.NPID into p_npid
-- from ne_info_table ne, subnetwork_table sub
-- where ne.NENODEID = circuit_bs_tbl_data(i).CKTNODEID
-- and ne.NeSubNetworkid=sub.subnetid;
--
-- exception
-- when no_data_found then
-- raise create_circuit_failed;
-- END;
 
--Remove all old data from the tables if any
BEGIN
delete from circuit_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_ctp_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
insert into circuit_bs_tbl
values (
circuit_bs_tbl_data(i).CKTNODEID,
circuit_bs_tbl_data(i).CKTUNIQUEID,
circuit_bs_tbl_data(i).CKTNAME,
circuit_bs_tbl_data(i).CKTDESCRIPTION,
circuit_bs_tbl_data(i).CUSTOMERID,
circuit_bs_tbl_data(i).SERVICEID,
circuit_bs_tbl_data(i).CKTTYPE,
circuit_bs_tbl_data(i).CKTSIZE,
circuit_bs_tbl_data(i).CKTDIRECTION,
circuit_bs_tbl_data(i).CKTISMONITOR,
circuit_bs_tbl_data(i).CKTSTATE,
circuit_bs_tbl_data(i).CKTENHANCEDSTATE,
circuit_bs_tbl_data(i).CKTPROTECTIONTYPE,
circuit_bs_tbl_data(i).CKTADDITIONALINFO,
circuit_bs_tbl_data(i).CKTCOMMENT,
circuit_bs_tbl_data(i).CKTUSElAP,
circuit_bs_tbl_data(i).CKTOCHNCCHANNEL,
circuit_bs_tbl_data(i).CKTOCHNCDIR,
circuit_bs_tbl_data(i).ISDUPLICATENAME,
p_npid
);
 
For I IN circuit_ctp_tbl_data.FIRST .. circuit_ctp_tbl_data.LAST
LOOP
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_ctp_tbl_data(i).CTPNODEID;
exception
when no_data_found then
raise create_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CTPACCESSID,
circuit_ctp_tbl_data(i).CTP_TYPE,
circuit_ctp_tbl_data(i).CKTNODEID,
circuit_ctp_tbl_data(i).CKTUNIQUEID,
circuit_ctp_tbl_data(i).CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_ctp_tbl_data(i).CTPMODULETYPE,
circuit_ctp_tbl_data(i).CTPIFINDEX,
circuit_ctp_tbl_data(i).CTPOBJECTINDEX,
circuit_ctp_tbl_data(i).CTPPHYSICALLOC,
circuit_ctp_tbl_data(i).CKTMODELTYPE,
circuit_ctp_tbl_data(i).CTPDROPPROT,
circuit_ctp_tbl_data(i).CKTCTPPATHPROT,
circuit_ctp_tbl_data(i).CTPDROPPROTTYPE,
circuit_ctp_tbl_data(i).CTPPORTNAME,
circuit_ctp_tbl_data(i).CTPADDITIONALINFO,
p_npid
);
END LOOP;
 
if (circuit_span_bs_tbl_data.count = 0) then
goto skip_circuit_span_bs_tbl;
end if;
 
For I IN circuit_span_bs_tbl_data.FIRST .. circuit_span_bs_tbl_data.LAST
LOOP
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_span_bs_tbl_data(i).SRC_CTPNODEID;
exception
when no_data_found then
raise create_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANSRCCTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CKTSPANSRCCTPACCESSID,
circuit_span_bs_tbl_data(i).SRC_CTP_TYPE,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).SRC_CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_span_bs_tbl_data(i).SRC_CTPMODULETYPE,
circuit_span_bs_tbl_data(i).SRC_CTPIFINDEX,
circuit_span_bs_tbl_data(i).SRC_CTPOBJECTINDEX,
circuit_span_bs_tbl_data(i).SRC_CTPPHYSICALLOC,
circuit_span_bs_tbl_data(i).SRC_CKTMODELTYPE,
null,
null,
null,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
null,
p_npid
);
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_span_bs_tbl_data(i).DST_CTPNODEID;
exception
when no_data_found then
raise create_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANDSTCTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CKTSPANDSTCTPACCESSID,
circuit_span_bs_tbl_data(i).DST_CTP_TYPE,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).DST_CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_span_bs_tbl_data(i).DST_CTPMODULETYPE,
circuit_span_bs_tbl_data(i).DST_CTPIFINDEX,
circuit_span_bs_tbl_data(i).DST_CTPOBJECTINDEX,
circuit_span_bs_tbl_data(i).DST_CTPPHYSICALLOC,
circuit_span_bs_tbl_data(i).DST_CKTMODELTYPE,
null,
null,
null,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
null,
p_npid
);
 
SELECT CKTSPANBSID_SEQ.nextval INTO i_CKTSPANBSID FROM dual;
 
insert into circuit_span_bs_tbl
values (
i_CKTSPANBSID,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).CKTLINKID,
circuit_span_bs_tbl_data(i).SPAN_TYPE,
i_CKTSPANSRCCTPACCESSID,
i_CKTSPANDSTCTPACCESSID,
circuit_span_bs_tbl_data(i).CKTSPANSRCSTATE,
circuit_span_bs_tbl_data(i).CKTSPANDESTSTATE,
circuit_span_bs_tbl_data(i).ISCKTFORWARDING,
circuit_span_bs_tbl_data(i).SCKTSPANINUPSR,
circuit_span_bs_tbl_data(i).ISCKTSPANWORKING,
circuit_span_bs_tbl_data(i).ISCKTSPANACTIVE,
circuit_span_bs_tbl_data(i).CKTSPANPROTOP,
circuit_span_bs_tbl_data(i).CKTSPANCDLFLOWID,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
p_npid
);
END LOOP;
 
<<skip_circuit_span_bs_tbl>>
null;
 
commit;
END;
 
Procedure update_circuit
(
circuit_bs_tbl_data IN circuit_bs_tbl_struct_list,
circuit_ctp_tbl_data IN circuit_ctp_tbl_struct_list,
circuit_span_bs_tbl_data IN circuit_span_bs_tbl_st_list
)
IS
p_npid NUMBER(1);
i number;
i_CTPACCESSID NUMBER;
i_CKTSPANBSID NUMBER;
update_circuit_failed EXCEPTION;
i_CKTSPANSRCCTPACCESSID NUMBER;
i_CKTSPANDSTCTPACCESSID NUMBER;
p_CKTCTPNeDBAccessId NUMBER;
BEGIN
i := circuit_bs_tbl_data.FIRST;
p_npid := circuit_bs_tbl_data(i).NPID;
 
BEGIN
update circuit_bs_tbl
set
CKTNAME = circuit_bs_tbl_data(i).CKTNAME,
CKTTYPE = circuit_bs_tbl_data(i).CKTTYPE,
CKTSIZE = circuit_bs_tbl_data(i).CKTSIZE,
CKTISMONITOR = circuit_bs_tbl_data(i).CKTISMONITOR,
CKTSTATE = circuit_bs_tbl_data(i).CKTSTATE,
CKTENHANCEDSTATE = circuit_bs_tbl_data(i).CKTENHANCEDSTATE,
CKTPROTECTIONTYPE = circuit_bs_tbl_data(i).CKTPROTECTIONTYPE,
CKTADDITIONALINFO = circuit_bs_tbl_data(i).CKTADDITIONALINFO,
CKTUSElAP = circuit_bs_tbl_data(i).CKTUSElAP,
CKTOCHNCCHANNEL = circuit_bs_tbl_data(i).CKTOCHNCCHANNEL,
CKTOCHNCDIR = circuit_bs_tbl_data(i).CKTOCHNCDIR,
ISDUPLICATENAME = circuit_bs_tbl_data(i).ISDUPLICATENAME
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
--No record. Cannot do update. Let application handle the exception.
exception
when no_data_found then
raise update_circuit_failed;
END;
 
--For circuit_ctp_tbl and circuit_span_bs_tbl, do delete and insert, not update
BEGIN
delete from circuit_ctp_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
For I IN circuit_ctp_tbl_data.FIRST .. circuit_ctp_tbl_data.LAST
LOOP
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_ctp_tbl_data(i).CTPNODEID;
exception
when no_data_found then
raise update_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CTPACCESSID,
circuit_ctp_tbl_data(i).CTP_TYPE,
circuit_ctp_tbl_data(i).CKTNODEID,
circuit_ctp_tbl_data(i).CKTUNIQUEID,
circuit_ctp_tbl_data(i).CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_ctp_tbl_data(i).CTPMODULETYPE,
circuit_ctp_tbl_data(i).CTPIFINDEX,
circuit_ctp_tbl_data(i).CTPOBJECTINDEX,
circuit_ctp_tbl_data(i).CTPPHYSICALLOC,
circuit_ctp_tbl_data(i).CKTMODELTYPE,
circuit_ctp_tbl_data(i).CTPDROPPROT,
circuit_ctp_tbl_data(i).CKTCTPPATHPROT,
circuit_ctp_tbl_data(i).CTPDROPPROTTYPE,
circuit_ctp_tbl_data(i).CTPPORTNAME,
circuit_ctp_tbl_data(i).CTPADDITIONALINFO,
p_npid
);
END LOOP;
 
if (circuit_span_bs_tbl_data.count = 0) then
goto skip_circuit_span_bs_tbl;
end if;
 
For I IN circuit_span_bs_tbl_data.FIRST .. circuit_span_bs_tbl_data.LAST
LOOP
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_span_bs_tbl_data(i).SRC_CTPNODEID;
exception
when no_data_found then
raise update_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANSRCCTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CKTSPANSRCCTPACCESSID,
circuit_span_bs_tbl_data(i).SRC_CTP_TYPE,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).SRC_CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_span_bs_tbl_data(i).SRC_CTPMODULETYPE,
circuit_span_bs_tbl_data(i).SRC_CTPIFINDEX,
circuit_span_bs_tbl_data(i).SRC_CTPOBJECTINDEX,
circuit_span_bs_tbl_data(i).SRC_CTPPHYSICALLOC,
circuit_span_bs_tbl_data(i).SRC_CKTMODELTYPE,
null,
null,
null,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
null,
p_npid
);
 
BEGIN
select NEDBACCESSID into p_CKTCTPNeDBAccessId
from ne_info_table
where NENODEID = circuit_span_bs_tbl_data(i).DST_CTPNODEID;
exception
when no_data_found then
raise update_circuit_failed;
END;
 
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANDSTCTPACCESSID FROM dual;
 
insert into circuit_ctp_tbl
values (
i_CKTSPANDSTCTPACCESSID,
circuit_span_bs_tbl_data(i).DST_CTP_TYPE,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).DST_CTPNODEID,
p_CKTCTPNeDBAccessId,
circuit_span_bs_tbl_data(i).DST_CTPMODULETYPE,
circuit_span_bs_tbl_data(i).DST_CTPIFINDEX,
circuit_span_bs_tbl_data(i).DST_CTPOBJECTINDEX,
circuit_span_bs_tbl_data(i).DST_CTPPHYSICALLOC,
circuit_span_bs_tbl_data(i).DST_CKTMODELTYPE,
null,
null,
null,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
null,
p_npid
);
 
SELECT CKTSPANBSID_SEQ.nextval INTO i_CKTSPANBSID FROM dual;
 
insert into circuit_span_bs_tbl
values (
i_CKTSPANBSID,
circuit_span_bs_tbl_data(i).CKTNODEID,
circuit_span_bs_tbl_data(i).CKTUNIQUEID,
circuit_span_bs_tbl_data(i).CKTLINKID,
circuit_span_bs_tbl_data(i).SPAN_TYPE,
i_CKTSPANSRCCTPACCESSID,
i_CKTSPANDSTCTPACCESSID,
circuit_span_bs_tbl_data(i).CKTSPANSRCSTATE,
circuit_span_bs_tbl_data(i).CKTSPANDESTSTATE,
circuit_span_bs_tbl_data(i).ISCKTFORWARDING,
circuit_span_bs_tbl_data(i).SCKTSPANINUPSR,
circuit_span_bs_tbl_data(i).ISCKTSPANWORKING,
circuit_span_bs_tbl_data(i).ISCKTSPANACTIVE,
circuit_span_bs_tbl_data(i).CKTSPANPROTOP,
circuit_span_bs_tbl_data(i).CKTSPANCDLFLOWID,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
p_npid
);
END LOOP;
 
<<skip_circuit_span_bs_tbl>>
null;
 
commit;
END;
 
Procedure update_circuit_ctps
(
p_nedbaccessid IN NUMBER,
p_ckt_min_physicalloc IN NUMBER,
p_ckt_max_physicalloc IN NUMBER,
p_cktmoduletype IN NUMBER,
cktmoduletype_upd_flag IN NUMBER,
p_cktportname IN VARCHAR2,
cktportname_udp_flag IN NUMBER
)
IS
rows_processed number :=0;
cursor_handle INTEGER := DBMS_SQL.OPEN_CURSOR;
statement_txt varchar2(500);
BEGIN
--Nothing to be updated
if(cktmoduletype_upd_flag = 0 and cktportname_udp_flag = 0) then
return;
end if;
 
statement_txt := 'update circuit_ctp_tbl set ';
if (cktmoduletype_upd_flag = 1) then
statement_txt := statement_txt || 'CKTCTPMODULETYPE = ' || p_cktmoduletype;
end if;
 
if (cktportname_udp_flag = 1) then
statement_txt := statement_txt || ', CKTCTPPORTNAME = ' || '''' ||p_cktportname||'''';
end if;
 
statement_txt := statement_txt || ' where CTPACCESSID = ' || p_nedbaccessid
|| ' and CKTCTPPHYSICALLOC between ' || p_ckt_min_physicalloc
|| ' and ' || p_ckt_max_physicalloc;
 
--dbms_output.put_line(statement_txt);
 
DBMS_SQL.PARSE(cursor_handle,statement_txt, DBMS_SQL.NATIVE);
 
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
 
IF (rows_processed=0) THEN
dbms_output.put_line('No record found');
--DBMS_SQL.CLOSE_CURSOR (cursor_handle);
END IF;
 
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
 
commit;
END;
 
Procedure delete_circuit
(
circuit_id_list IN circuit_identity_struct_list,
delcomp IN NUMBER
)
IS
i number;
BEGIN
 
For I IN circuit_id_list.FIRST .. circuit_id_list.LAST
LOOP
if(delcomp = 0) then
goto continue_loop;
end if;
 
BEGIN
delete from circuit_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from CIRCUIT_VCG_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
<<continue_loop>>
null;
 
BEGIN
delete from circuit_ctp_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
 
exception
when no_data_found then
null;
END;
END LOOP;
 
commit;
 
END;
 
Procedure delete_circuits_on_nodeList
(
circuit_id_list IN circuit_identity_struct_list
)
IS
i number;
BEGIN
For I IN circuit_id_list.FIRST .. circuit_id_list.LAST
LOOP
BEGIN
delete from circuit_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
exception
when no_data_found then
null;
END;
 
BEGIN
delete from CIRCUIT_VCG_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID;
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_ctp_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
 
exception
when no_data_found then
null;
END;
 
BEGIN
delete from CIRCUIT_VLAN_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID;
 
exception
when no_data_found then
null;
END;
 
END LOOP;
 
commit;
END;
 
END MSMCircuit;
/

3.1.3 prune_package

3.1.3.1 小規模構成用のprune_package

CREATE OR REPLACE PACKAGE Prune AS
 
row_count NUMBER := 0 ;
rows_to_be_deleted NUMBER := 100000 ;
ORACLE_SID varchar2(40);
 
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE );
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE );
PROCEDURE prune_auditlog( intervaldays IN Number);
PROCEDURE prune_errorlog(intervaldays IN number) ;
PROCEDURE prune_fm( intervaldays IN number);
PROCEDURE prune_audittrail( intervaldays IN number);
PROCEDURE prune_server_monitor( intervaldays IN number);
PROCEDURE prune_admin_job_table( intervaldays IN number);
 
END Prune ;
/
CREATE OR REPLACE PACKAGE BODY Prune AS
 
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
CURSOR IsThisAGNE IS
SELECT gne.gneid
FROM gne_table gne, ne_info_Table ne
WHERE gne.gnesysid = ne.nesysid AND
ne.nesysid = iv_NESysId ;
 
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
SELECT ne.nesysid
FROM ne_info_table ne
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysId ;
 
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
BEGIN
OPEN IsThisAGNE ;
FETCH IsThisAGNE INTO lv_GNEId ;
IF IsThisAGNE%FOUND THEN
FOR rec IN GneChildren(lv_GNEId) LOOP
dbms_output.put_line('NE : '||rec.nesysid);
END LOOP ;
END IF ;
CLOSE IsThisAGNE ;
END CheckGne ;
 
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
CURSOR IsThisAGNE IS
SELECT gne.gneid
FROM gne_table gne
WHERE gne.gnesysid = iv_NESysid ;
 
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
SELECT ne.nesysid
FROM ne_info_table ne
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysid ;
 
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
lv_NESysId ne_info_table.NESysId%TYPE := NULL ;
BEGIN
OPEN IsThisAGNE ;
FETCH IsThisAGNE INTO lv_GNEId ;
IF IsThisAGNE%FOUND THEN
OPEN GneChildren (lv_GNEId ) ;
FETCH GneChildren INTO lv_NESysId ;
IF GNEChildren%NOTFOUND THEN
DELETE gne_table
WHERE GNEId = lv_GNEId ;
COMMIT ;
END IF ;
END IF ;
CLOSE IsThisAGNE ;
END PruneGNE ;
 
PROCEDURE prune_auditlog( intervaldays IN number ) AS
prunedate date;
counter number:=0;
rows_processed number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
IF ( intervaldays != -1 ) THEN
prunedate:=sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Starting prune auditlog at '||sysdate);
 
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Prune transaction log table before '||prunedate);
 
FOR i IN (select rowid from transaction_log_table
where timestamp < prunedate ) LOOP
rowid_tab_v(counter) := i.rowid;
counter := counter + 1;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN rowid_tab_v.FIRST .. rowid_tab_v.LAST
DELETE FROM transaction_log_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
END LOOP;
IF counter < rows_to_be_deleted AND counter > 0 THEN
FORALL rid IN rowid_tab_v.FIRST .. rowid_tab_v.LAST
DELETE FROM transaction_log_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
 
dbms_output.put_line('Deleted '||rows_processed||' rows from transaction_log_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Deleted '||rows_processed||' rows from transaction_log_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Finish prune transaction log table at '||sysdate);
COMMIT ;
ELSE
dbms_output.put_line('user choose to keep all audit log data, so no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.err','Error in pruning audit log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_errorlog(intervaldays IN number) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1) THEN
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Starting prune errorlog at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Prune error log table data before '||prunedate);
 
FOR i IN (select rowid from ERROR_LOG_TABLE
where timestamp < prunedate ) LOOP
rowid_tab_v(counter) := i.rowid;
counter := counter + 1;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN rowid_tab_v.FIRST .. rowid_tab_v.LAST
DELETE FROM error_log_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
END LOOP;
 
IF counter < rows_to_be_deleted AND counter > 0 THEN
FORALL rid IN rowid_tab_v.FIRST .. rowid_tab_v.LAST
DELETE FROM error_log_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
 
 
dbms_output.put_line('Deleted '||rows_processed||' rows from error_log_table ');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Deleted '||rows_processed||' rows from error_log_table ');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Finish prune error log table at '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
ELSE
dbms_output.put_line('User choose to keep all data, no prune');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.err','Error in pruning error log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_fm(intervaldays IN number ) AS
prunedate date;
counter number :=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1) THEN
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Starting prune fm at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Prune FM data before '||prunedate);
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from alarm_event_table
where AlarmEventTimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted '||rows_processed||' rows from alarm_event_table at '|| sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
FOR i IN (select rowid from ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and alarmstatus = 1
and ackindex <> 0
and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted '||rows_processed||' rows from active_alarm_table at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Finish prune FM at '||sysdate);
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.err','Error in pruning fm log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_audittrail( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Starting prune audittrail at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Prune audit trail table before '||prunedate);
 
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from NE_Audit_Trail_Table
where TIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM NE_Audit_Trail_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM NE_Audit_Trail_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Deleted '||rows_processed||' rows from NE_Audit_Trail_Table at '|| sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Finish prune audittrail at '||sysdate);
 
LOOP
counter:=0;
FOR i IN (select rowid from ONS158XX_LAC_LOG_TABLE
where DateTime < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LAC_LOG_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LAC_LOG_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Deleted '||rows_processed||' rows from ONS158XX_LAC_LOG_TABLE at '|| sysdate);
 
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.err','Error in audit trail log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_server_monitor( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Starting prune server monitor table at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Prune server monitor table before '||prunedate);
 
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from SERVER_MONITOR_TABLE
where CollectionTime < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM SERVER_MONITOR_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM SERVER_MONITOR_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Deleted '||rows_processed||' rows from SERVER_MONITOR_TABLE at '|| sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Finish prune server monitor table at '||sysdate);
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.err','Error in prune server monitor table '||SQLERRM||', '||SQLCODE);
END;
 
 
PROCEDURE prune_admin_job_table( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Starting prune admin job table at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Prune admin job table before '||prunedate);
 
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from ADMIN_JOB_TABLE
where ScheduledTIme < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Deleted '||rows_processed||' rows from ADMIN_JOB_TABLE at '|| sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Finish prune admin job table at '||sysdate);
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error in prune admin job table '||SQLERRM||', '||SQLCODE);
END;
 
 
 
END prune;
/
 

3.1.3.2 中規模、大規模およびハイエンド構成用の prune_package

CREATE OR REPLACE PACKAGE Prune AS
 
row_count NUMBER := 0 ;
rows_to_be_deleted NUMBER := 100000 ;
ORACLE_SID varchar2(40);
 
PROCEDURE Prune_log(p_table_name in varchar2, intervaldays in number, log_file in varchar2);
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE );
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE );
PROCEDURE prune_auditlog( intervaldays IN Number);
PROCEDURE prune_errorlog(intervaldays IN number) ;
PROCEDURE prune_fm( intervaldays IN number);
PROCEDURE prune_audittrail( intervaldays IN number);
PROCEDURE prune_server_monitor( intervaldays IN number);
PROCEDURE prune_admin_job_table( intervaldays IN number);
 
END Prune ;
/
 
CREATE OR REPLACE PACKAGE BODY Prune AS
PROCEDURE Prune_log(p_table_name in varchar2, intervaldays in number, log_file in varchar2)
AS
partition_to_be_pruned varchar2(9);
cursor_handle integer;
cursor_handle_1 integer;
statement_txt varchar2(500);
statement_txt_1 varchar2(500);
rows_processed number := 0;
rows_processed_1 number :=0;
 
prunedate date;
deleted_rows number;
ORACLE_SID varchar2(20);
err_file varchar2(500);
 
BEGIN
err_file := 'prune_'||p_table_name||'.err';
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1) THEN
prunedate:= sysdate-intervaldays;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',log_file,'prune data in '||p_table_name||' before '||prunedate);
prunedate:= trunc(sysdate-intervaldays);
 
FOR rec IN ( SELECT table_name, index_name,column_name FROM user_ind_columns
WHERE table_name = p_table_name
AND column_name like '%TIME%'
AND column_position=1)
LOOP
 
cursor_handle_1 := DBMS_SQL.OPEN_CURSOR;
statement_txt_1 := 'SELECT count(rowid) FROM '||rec.table_name||' where '||rec.column_name ||'<= '||''''||prunedate||'''';
--DBMS_OUTPUT.PUT_LINE(statement_txt_1);
DBMS_SQL.PARSE(cursor_handle_1, statement_txt_1, DBMS_SQL.NATIVE);
 
DBMS_SQL.DEFINE_COLUMN ( cursor_handle_1,1, deleted_rows);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle_1);
IF DBMS_SQL.FETCH_ROWS(cursor_handle_1)=0 then
EXIT;
ELSE
DBMS_SQL.COLUMN_VALUE (cursor_handle_1,1, deleted_rows);
deleted_rows :=nvl(deleted_rows,0);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',log_file,'pruned '||deleted_rows||' from '||rec.table_name);
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle_1);
 
FOR i IN ( SELECT partition_name FROM user_segments
Where to_date(substr(partition_name,2,9)) <= prunedate
AND segment_name=rec.table_name)
LOOP
--dbms_output.put_line(i.partition_name);
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop partition '||i.partition_name;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',log_file,'dropped partition '||i.partition_name||' from '||rec.table_name);
END LOOP;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',log_file,'prune '||p_table_name||' successfully finished at '||sysdate);
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',err_file,'Error in pruning '||p_table_name||': '||SQLERRM||', '||SQLCODE);
END prune_log;
 
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
CURSOR IsThisAGNE IS
SELECT gne.gneid
FROM gne_table gne, ne_info_Table ne
WHERE gne.gnesysid = ne.nesysid AND
ne.nesysid = iv_NESysId ;
 
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
SELECT ne.nesysid
FROM ne_info_table ne
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysId ;
 
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
BEGIN
OPEN IsThisAGNE ;
FETCH IsThisAGNE INTO lv_GNEId ;
IF IsThisAGNE%FOUND THEN
FOR rec IN GneChildren(lv_GNEId) LOOP
dbms_output.put_line('NE : '||rec.nesysid);
END LOOP ;
END IF ;
CLOSE IsThisAGNE ;
END CheckGne ;
 
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
CURSOR IsThisAGNE IS
SELECT gne.gneid
FROM gne_table gne
WHERE gne.gnesysid = iv_NESysid ;
 
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
SELECT ne.nesysid
FROM ne_info_table ne
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysid ;
 
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
lv_NESysId ne_info_table.NESysId%TYPE := NULL ;
BEGIN
OPEN IsThisAGNE ;
FETCH IsThisAGNE INTO lv_GNEId ;
IF IsThisAGNE%FOUND THEN
OPEN GneChildren (lv_GNEId ) ;
FETCH GneChildren INTO lv_NESysId ;
IF GNEChildren%NOTFOUND THEN
DELETE gne_table
WHERE GNEId = lv_GNEId ;
COMMIT ;
END IF ;
END IF ;
CLOSE IsThisAGNE ;
END PruneGNE ;
 
PROCEDURE prune_auditlog( intervaldays IN number ) AS
prunedate date;
counter number:=0;
rows_processed number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
IF ( intervaldays != -1 ) THEN
prunedate:=sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Starting prune auditlog at '||sysdate);
prune_log ('TRANSACTION_LOG_TABLE', intervaldays, 'prune_auditlog.log');
ELSE
dbms_output.put_line('user choose to keep all audit log data, so no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.err','Error in pruning audit log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_errorlog(intervaldays IN number) AS
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Starting prune errorlog at '||sysdate);
prune_log('ERROR_LOG_TABLE', intervaldays, 'prune_errorlog.log');
END;
 
PROCEDURE prune_fm(intervaldays IN number ) AS
prunedate date;
counter number :=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1) THEN
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Starting prune fm at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Prune FM data before '||prunedate);
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from alarm_event_table
where AlarmEventTimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted '||rows_processed||' rows from alarm_event_table at '|| sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
FOR i IN (select rowid from ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and alarmstatus = 1
and ackindex <> 0
and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted '||rows_processed||' rows from active_alarm_table at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Finish prune FM at '||sysdate);
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.err','Error in pruning fm log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_audittrail( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Starting prune audittrail at '||sysdate);
 
prune_log('NE_AUDIT_TRAIL', intervaldays, 'prune_audittrail.log');
prune_log('ONS158XX_LAC_LOG_TABLE', intervaldays, 'prune_audittrail.log');
 
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.err','Error in audit trail log '||SQLERRM||', '||SQLCODE);
END;
 
PROCEDURE prune_server_monitor( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Starting prune server monitor table at '||sysdate);
prune_log('SERVER_MONITOR_TABLE', intervaldays, 'prune_servermonitor.log');
 
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.err','Error in prune server monitor table '||SQLERRM||', '||SQLCODE);
END;
 
 
PROCEDURE prune_admin_job_table( intervaldays IN number ) AS
prunedate date;
counter number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_processed number :=0;
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
IF ( intervaldays != -1 ) THEN
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Starting prune admin job table at '||sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Prune admin job table before '||prunedate) ;
counter:=0;
rows_processed :=0;
LOOP
counter:=0;
FOR i IN (select rowid from ADMIN_JOB_TABLE
where ScheduledTIme < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
 
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP ;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Deleted '||rows_processed||' rows from ADMIN_JOB_TABLE at '|| sysdate);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Finish prune admin job table at '||sysdate);
 
ELSE
dbms_output.put_line('User choose to keep all data, no prune at this time');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','User choose to keep all data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error in prune admin job table '||SQLERRM||', '||SQLCODE);
END;
 
 
 
END prune;
/

3.2 CTM ストアド プロシージャ

この項では、CTM テーブルで定義されているプロシージャの内容を示します。プロシージャはアルファベット順に示されています。

3.2.1 add_circuit_ctps_to_met

CREATE or REPLACE PROCEDURE add_circuit_ctps_to_met
(
p_CktNodeId IN NUMBER,
p_CktUniqueId IN NUMBER
)
AS
p_CustomerId varchar2(256);
p_ServiceId varchar2(256);
p_CktType number(2);
p_PHYSICALLOC number(20);
p_ifindex number(20);
p_objecttype number(10);
p_MODULETYPE number(8);
p_NEDBAccessID number(10);
BEGIN
BEGIN
select c.CktType, c.CustomerId, c.ServiceId,
c.CKTSRCMODULETYPE,
c.CKTSRCPHYSICALLOC,
c.CKTSRCIFINDEX,
c.CKTSRCOBJECTTYPE, n.NEDBAccessID
into p_CktType, p_CustomerId, p_ServiceId, p_MODULETYPE,
p_PHYSICALLOC, p_ifindex, p_objecttype, p_NEDBAccessID
from circuit_tbl c, ne_info_table n
where c.CktNodeId = p_CktNodeId
and c.CktUniqueId = p_CktUniqueId
and c.CKTSRCNODEID = n.NENodeID
and c.CKTSRCNODEID != 0;
EXCEPTION
WHEN NO_DATA_FOUND then
goto END_OF_PROCEDURE;
END;
 
BEGIN
insert into Managed_Et_tab
(
Mng_Entity_Type,
Mng_Entity_Id_Num,
Mng_Entity_Id2_Num,
NeDBAccessId,
FIELD1_Num,
FIELD2_Num,
FIELD3_Num,
FIELD4_Num,
Customer_Id_Str,
Service_Id_Str
)
values
(
p_CktType,
p_CktNodeId,
p_CktUniqueId,
p_NEDBAccessID,
p_MODULETYPE,
p_PHYSICALLOC,
p_ifindex,
p_objecttype,
p_CustomerId,
p_ServiceId
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX then
update Managed_Et_tab
set
FIELD4_Num = p_objecttype,
Customer_Id_Str = p_CustomerId,
Service_Id_Str = p_ServiceId
where Mng_Entity_Type = p_CktType
and Mng_Entity_Id_Num = p_CktNodeId
and Mng_Entity_Id2_Num = p_CktUniqueId
and NeDBAccessId = p_NEDBAccessID
and FIELD1_Num = p_MODULETYPE
and FIELD2_Num = p_PHYSICALLOC
and FIELD3_Num = p_ifindex;
END;
 
BEGIN
select c.CKTSECSRCMODULETYPE,
c.CKTSECSRCPHYSICALLOC,
c.CKTSECSRCIFINDEX,
c.CKTSECSRCOBJECTTYPE, n.NEDBAccessID
into p_MODULETYPE,
p_PHYSICALLOC, p_ifindex, p_objecttype, p_NEDBAccessID
from circuit_tbl c, ne_info_table n
where c.CktNodeId = p_CktNodeId
and c.CktUniqueId = p_CktUniqueId
and c.CKTSECSRCNODEID = n.NENodeID
and c.CKTSECSRCNODEID != 0;
EXCEPTION
WHEN NO_DATA_FOUND then
goto NEXT_SELECTION;
END;
 
BEGIN
insert into Managed_Et_tab
(
Mng_Entity_Type,
Mng_Entity_Id_Num,
Mng_Entity_Id2_Num,
NeDBAccessId,
FIELD1_Num,
FIELD2_Num,
FIELD3_Num,
FIELD4_Num,
Customer_Id_Str,
Service_Id_Str
)
values
(
p_CktType,
p_CktNodeId,
p_CktUniqueId,
p_NEDBAccessID,
p_MODULETYPE,
p_PHYSICALLOC,
p_ifindex,
p_objecttype,
p_CustomerId,
p_ServiceId
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX then
update Managed_Et_tab
set
FIELD4_Num = p_objecttype,
Customer_Id_Str = p_CustomerId,
Service_Id_Str = p_ServiceId
where Mng_Entity_Type = p_CktType
and Mng_Entity_Id_Num = p_CktNodeId
and Mng_Entity_Id2_Num = p_CktUniqueId
and NeDBAccessId = p_NEDBAccessID
and FIELD1_Num = p_MODULETYPE
and FIELD2_Num = p_PHYSICALLOC
and FIELD3_Num = p_ifindex;
END;
 
<<NEXT_SELECTION>>
null;
 
FOR rec IN (
select t.CktDestModuleType, t.CktDestPhysicalLoc, t.CktDestIfIndex,
t.CktDestObjectType, n.NEDBAccessID
from circuit_dest_tbl t, ne_info_table n
where t.CktNodeId = p_CktNodeId
and t.CktUniqueId = p_CktUniqueId
and t.CktDestNodeId = n.NENodeID
and t.CktDestNodeId != 0
)
LOOP
BEGIN
insert into Managed_Et_tab
(
Mng_Entity_Type,
Mng_Entity_Id_Num,
Mng_Entity_Id2_Num,
NeDBAccessId,
FIELD1_Num,
FIELD2_Num,
FIELD3_Num,
FIELD4_Num,
Customer_Id_Str,
Service_Id_Str
)
values
(
p_CktType,
p_CktNodeId,
p_CktUniqueId,
rec.NEDBAccessID,
rec.CktDestModuleType,
rec.CktDestPhysicalLoc,
rec.CktDestIfIndex,
rec.CktDestObjectType,
p_CustomerId,
p_ServiceId
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX then
update Managed_Et_tab
set
FIELD4_Num = rec.CktDestObjectType,
Customer_Id_Str = p_CustomerId,
Service_Id_Str = p_ServiceId
where Mng_Entity_Type = p_CktType
and Mng_Entity_Id_Num = p_CktNodeId
and Mng_Entity_Id2_Num = p_CktUniqueId
and NeDBAccessId = rec.NEDBAccessID
and FIELD1_Num = rec.CktDestModuleType
and FIELD2_Num = rec.CktDestPhysicalLoc
and FIELD3_Num = rec.CktDestIfIndex;
END;
END LOOP;
 
FOR rec IN (
select v.DESTNEMODULETYPE CktDestModuleType,
v.DESTPHYSICALLOC CktDestPhysicalLoc,
v.INTERFACEID CktDestIfIndex,
v.DESTOBJECTTYPE CktDestObjectType, v.DESTNEDBACCESSID NEDBAccessID
from circuit_span_view v
where v.NODEID = p_CktNodeId
and v.UNIQUEID = p_CktUniqueId
)
LOOP
BEGIN
insert into Managed_Et_tab
(
Mng_Entity_Type,
Mng_Entity_Id_Num,
Mng_Entity_Id2_Num,
NeDBAccessId,
FIELD1_Num,
FIELD2_Num,
FIELD3_Num,
FIELD4_Num,
Customer_Id_Str,
Service_Id_Str
)
values
(
p_CktType,
p_CktNodeId,
p_CktUniqueId,
rec.NEDBAccessID,
rec.CktDestModuleType,
rec.CktDestPhysicalLoc,
rec.CktDestIfIndex,
rec.CktDestObjectType,
p_CustomerId,
p_ServiceId
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX then
update Managed_Et_tab
set
FIELD4_Num = rec.CktDestObjectType,
Customer_Id_Str = p_CustomerId,
Service_Id_Str = p_ServiceId
where Mng_Entity_Type = p_CktType
and Mng_Entity_Id_Num = p_CktNodeId
and Mng_Entity_Id2_Num = p_CktUniqueId
and NeDBAccessId = rec.NEDBAccessID
and FIELD1_Num = rec.CktDestModuleType
and FIELD2_Num = rec.CktDestPhysicalLoc
and FIELD3_Num = rec.CktDestIfIndex;
END;
END LOOP;
 
<<END_OF_PROCEDURE>>
null;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
END;
/

3.2.2 add_log_partition


) add_log_partition プロシージャは、中規模、大規模およびハイエンド用構成だけを対象にします。


create or replace procedure add_log_partition AS
partition_to_be_added varchar2(9);
cursor_handle integer;
statement_txt varchar2(500);
rows_processed number := 0;
 
p_tablespace_name varchar2(25);
 
new_partition_date date;
new_partition_name varchar2(9);
ORACLE_SID varchar2(20);
add_flag number;
 
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log','Starting adding partition at '||sysdate);
FOR rec IN ( SELECT table_name FROM user_tables
WHERE table_name in (
'ERROR_LOG_TABLE', 'SERVER_MONITOR_TABLE',
'TRANSACTION_LOG_TABLE',
'NE_AUDIT_TRAIL_TABLE', 'ONS158XX_LAC_LOG_TABLE'
))
 
LOOP
add_flag:=1;
Select max(to_date( substr(partition_name,2,9))),tablespace_name
INTO new_partition_date, p_tablespace_name
From user_segments
Where segment_name =rec.table_name
group by tablespace_name;
 
IF (sysdate >= new_partition_date) THEN
new_partition_date:=sysdate+1;
ELSIF (new_partition_date >= sysdate+3) THEN
add_flag:=0;
Else
new_partition_date:= new_partition_date+1;
END IF;
IF (add_flag=1) THEN
partition_to_be_added:= 'p'||to_char(new_partition_date,'mmddyyyy');
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' add partition '||partition_to_be_added||
' values less than ('||''''||new_partition_date||''''||')
TABLESPACE '||p_tablespace_name;
DBMS_OUTPUT.PUT_LINE(statement_txt);
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log','added partition '||partition_to_be_added||' to '||rec.table_name);
ELSE
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log',rec.table_name||' already has log partitions for the next 3 days');
END IF;
 
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log','Adding partition successfully finished at '||sysdate);
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.err','Error in adding pm partition '||SQLERRM||', '||SQLCODE);
END;
/
 

3.2.3 add_pm_partition


) add_pm_partition プロシージャは、中規模、大規模およびハイエンド用構成だけを対象にします。


create or replace procedure add_pm_partition AS
partition_to_be_added varchar2(9);
subpartition_15min_to_be_added varchar2(15);
subpartition_1day_to_be_added varchar2(14);
cursor_handle integer;
statement_txt varchar2(500);
rows_processed number := 0;
 
p_tablespace_name varchar2(25);
 
new_partition_date date;
new_partition_name varchar2(9);
ORACLE_SID varchar2(20);
pm_service_enabled varchar2(15);
add_flag number;
 
BEGIN
 
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','Starting adding partition at '||sysdate);
FOR rec IN ( SELECT table_name FROM user_tables
WHERE table_name like '%PM_TABLE'
AND TABLE_NAME !='ONS158XX_TIMESTAMP_PM_TABLE')
 
LOOP
add_flag:=1;
 
Select max(to_date( substr(partition_name,2,9))),tablespace_name
INTO new_partition_date, p_tablespace_name
From user_tab_partitions
Where table_name =rec.table_name
group by tablespace_name;
 
IF (sysdate >= new_partition_date) THEN
new_partition_date:=sysdate+1;
ELSIF (new_partition_date >= sysdate+3) THEN
add_flag:=0;
Else
new_partition_date:= new_partition_date+1;
END IF;
-- check whether pm-service is enabled, if no, no need to add partitions
begin
 
Select activevalue INTO pm_service_enabled
from ctm_config_table
where propertyname='pm-service'
and upper(rtrim(sectionname,'-pm'))=substr(rec.table_name,1,instr(rec.table_name,'_',1)-1) ;
exception
when NO_DATA_FOUND THEN
Select activevalue INTO pm_service_enabled
from ctm_config_table
where propertyname='pm-service'
and upper(rtrim(sectionname,'-pm'))=replace(substr(rec.table_name,1,instr(rec.table_name,'_',1)-1),'01','XX');
end;
IF (pm_service_enabled ='active' and add_flag=1) THEN
partition_to_be_added:= 'p'||to_char(new_partition_date,'mmddyyyy');
subpartition_15min_to_be_added := 'p15min_'||to_char(new_partition_date,'mmddyyyy');
subpartition_1day_to_be_added := 'p1day_'||to_char(new_partition_date,'mmddyyyy');
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
 
statement_txt := 'alter table '||rec.table_name ||' add partition '||partition_to_be_added||
' values less than ('||''''||new_partition_date||''''||')'
|| ' TABLESPACE '||p_tablespace_name;
 
statement_txt := statement_txt || ' ('
|| ' subpartition ' || subpartition_15min_to_be_added ||' values(0),'
|| ' subpartition ' || subpartition_1day_to_be_added ||' values(1)'
|| ')';
 
--DBMS_OUTPUT.PUT_LINE(statement_txt);
 
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','added partition '||partition_to_be_added||' to '||rec.table_name);
ELSE
IF (add_flag = 0 ) THEN
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',rec.table_name||' already has partitions for the next 3 days');
ELSE
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','pm-service is not enabled for this NE Type, no need to add partition to '||rec.table_name||' at this time');
END IF;
END IF;
 
END LOOP;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','Adding partition successfully finished at '||sysdate);
EXCEPTION
WHEN OTHERS THEN
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.err','Error in adding pm partition '||SQLERRM||', '||SQLCODE);
 
END;
/

3.2.4 alter_user_permission

create or replace PROCEDURE alter_user_permission
(UserTypeID IN number,
AddOrRemove IN varchar2,
error_msg OUT varchar2)
IS
r_userid number(4);
remove_failed EXCEPTION;
add_failed EXCEPTION;
BEGIN
IF (AddOrRemove = 'Remove') THEN
FOR rec IN (select userid FROM user_table
where subtypeofUser=userTypeId) LOOP
Begin
DELETE FROM user_map_table
WHERE userid=rec.userid
AND groupOrNeid=-2;
Exception
WHEN OTHERS THEN
error_msg:= 'Remove failed for userid '||rec.userid;
raise remove_failed;
END;
END LOOP;
commit;
END IF;
 
IF (AddOrRemove = 'Add') THEN
FOR rec IN (select userid FROM user_table
where subTypeOfUser=UserTypeId) LOOP
Begin
INSERT INTO user_map_table
VALUES (rec.userid, 2, -2);
Exception
WHEN OTHERS THEN
error_msg:= 'Add failed for userid '||rec.userid;
raise add_failed;
END;
END LOOP;
commit;
END IF;
END;
/
 

3.2.5 append_file

create or replace PROCEDURE append_file
(loc_in IN varchar2, file_in IN varchar2, line_in IN varchar2 :=null)
IS
 
file_handle utl_file.file_type;
BEGIN
 
file_handle := utl_file.fopen (loc_in, file_in,'A');
utl_file.put_line(file_handle,line_in);
utl_file.fclose(file_handle);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
dbms_output.put_line('Error in appending log file');
END;
/

3.2.6 BulkNEAddition

create or replace procedure BulkNEAddition
(OperationType IN number,
GroupToBeInserted IN number,
GroupName IN varchar2,
GroupDescription IN varchar2,
GroupLocationName IN varchar2,
GneToBeInserted IN number,
GneSysId IN varchar2,
NextHopIpAddr IN number,
GroupingOption IN number,
GroupPrefix IN varchar2,
inUserId IN number,
SubNWToBeInserted IN number,
SubNwName IN OUT varchar2,
SubnetType IN number,
SubnetTopology IN number,
NWPartitionId IN number,
Is216NE IN number,
InNeSysId IN varchar2,
Ipaddr IN number,
OperationalState IN number,
IsConnected IN number,
GneId IN OUT number,
NeDescription IN varchar2,
NeConfigMode IN number,
SnmpCommunityString IN varchar2,
ClliCode IN varchar2,
NeModelType IN number,
NeModelIndex IN number,
SubNwId IN OUT number,
SystemTitle IN varchar2,
UserLabel IN varchar2,
VendorName IN varchar2,
VersionName IN varchar2,
NePmEnabled IN number,
DisplayModelName IN varchar2,
GwTL1UserName IN varchar2,
GwTL1Password IN varchar2,
NeDiscState IN number,
pmCollectionFlag IN number,
PmTicket IN varchar2,
LaunchContext IN number,
ParentGroupId IN number,
NewGroupId OUT number,
NeId OUT number,
error_code OUT number,
error_msg OUT varchar)
IS
i_groupid number;
i_gneid number;
i_subNWName varchar2(64);
i_subnetid number;
i_Neid number;
i_parenttype number;
assigned_group number;
UserProperty number;
counter number:=0;
 
BulkNeAdd_FAILED EXCEPTION;
BEGIN
IF (GroupToBeInserted = 1) THEN
SELECT groupId_seq.nextval INTO i_groupId from dual;
INSERT INTO group_info_table
VALUES(i_groupid, GroupName,GroupDescription,'',GroupLocationName);
END IF;
 
IF (GneToBeInserted = 1) THEN
SELECT GNEID_SEQ.nextval INTO i_gneid from dual;
INSERT INTO gne_table
VALUES(i_gneid, 0,1, GneSysid,NextHopIpaddr,'',GroupingOption,GroupPrefix, inUserId);
ELSE
i_gneid:=GneId;
END IF;
 
IF (SubNWToBeInserted = 1) THEN
SELECT SUBNETID_SEQ.nextval INTO i_subnetid FROM dual;
IF (subNwName is null) THEN
SELECT 'Subnetwork-'||lpad(i_subnetid,8,'0')
INTO i_subNwName from dual;
SELECT count(*) INTO counter from subnetwork_table
WHERE subnetname=i_subNwName;
IF (counter>0) THEN
i_subNwName:=i_subNwName||'-1';
END IF;
ELSE
i_subNWName:=subNwName;
END IF;
INSERT INTO subnetwork_table
VALUES (i_subnetid, i_subNWName,'','',SubnetType, SubnetTopology,-1,NWPartitionId);
ELSE
i_subnetid :=SubNwId;
END IF;
 
SELECT NEDBACCESSID_SEQ.nextval INTO i_neid FROM dual;
 
INSERT INTO ne_info_table
VALUES (i_neid,
InNeSysID,
IpAddr,
'',
OperationalState,
isConnected,
i_gneid,
NeDescription,
neConfigMode,
SnmpCommunityString,
ClliCode,
'',
NeModelType,
NeModelIndex,
0,
i_subnetid,
0,
'',
systemTitle,
userLabel,
vendorName,
versionName,
0,
0,
0,
nepmenabled,
0,
0,
0,
0,
0,
0,
0,
0,
DisplayModelName,
GwTL1UserName,
GwTL1Password,
0,
0,
0,
null,
null,
NeDiscState,
pmCollectionFlag,
PmTicket,
'',
-1,
'',
0,
0
);
 
IF( Is216NE = 1 ) THEN
UPDATE NE_INFO_TABLE set NEIPADDR=''
WHERE NESYSID=InNeSysId;
END IF;
BEGIN
SELECT Properties INTO userProperty
FROM user_type_table
WHERE usertypeid = ( select subtypeofuser from user_table where userid = InUserId);
 
IF (userProperty =2) THEN
SELECT count(*) INTO assigned_group
FROM user_map_table
WHERE userid=inUserid
AND (GroupOrNEID IN ( SELECT parentid FROM domain_table
WHERE childType=2
START WITH parentid=parentGroupid
CONNECT by prior parentid=childid)
OR GroupOrNEID =parentGroupid);
IF (assigned_group = 0) THEN
IF (GroupToBeInserted =1) THEN
INSERT INTO user_map_table
VALUES (inUserId, 2, i_groupid);
ELSE
INSERT INTO user_map_table
VALUES(inUserId, 3, i_neid);
END IF;
END IF;
END IF;
Exception
WHEN NO_DATA_FOUND
THEN null;
END;
 
IF (parentGroupId = 0) THEN
i_parenttype:=1;
ELSE
i_parenttype:=2;
END IF;
 
IF (GroupToBeInserted = 1 ) THEN
insert into domain_table
values(DT_TREENODEID_SEQ.nextval, i_parenttype, parentGroupid, 2, i_groupid);
INSERT INTO domain_table
VALUES (DT_TREENODEID_SEQ.nextval, 2, i_groupid, 3,i_neid);
ELSE
INSERT INTO domain_table
VALUES (DT_TREENODEID_SEQ.nextval, i_parenttype, parentGroupid, 3,i_neid);
END IF;
 
INSERT INTO Cerent_Ne_Group_Table VALUES (i_neid, GroupingOption);
commit;
 
neId:= i_neid;
newGroupId:=i_groupid;
subNwname:=i_subNwName;
subNwId:=i_subnetId;
GneId:=i_GneId;
--create_file('/oraclesw9i','bulkneadd.log','neid:'||neId||' newGroupId:'||newGroupId||' subNwname:'||subNwname||' subNwId:'||subNwId||' GneId:'||GneId);
 
EXCEPTION
WHEN OTHERS THEN
error_code := SQLCODE;
error_msg:= SQLERRM;
raise BulkNeAdd_Failed;
rollback;
END;
/

3.2.7 clear_allunack_alarms

CREATE or REPLACE procedure clear_allunack_alarms
IS
counter number :=0;
BEGIN
UPDATE ctm_config_table
SET activevalue=1
WHERE propertyname='clear-unack-alarms'
AND sectionname='ui';
commit;
FOR rec IN (select rowid from active_alarm_table
where alarmstatus=1
and ackindex=0 ) LOOP
UPDATE active_alarm_table
SET ackindex=-1
WHERE rowid=rec.rowid;
counter:=counter+1;
IF mod(counter,1000)=0 THEN
commit;
END IF;
END LOOP;
dbms_output.put_line('Total '||counter||' cleared alarms are autoacknowledged');
commit;
UPDATE ctm_config_table
SET activevalue=0
WHERE propertyname='clear-unack-alarms'
AND sectionname='ui';
END;
/
 

3.2.8 create_file

create or replace PROCEDURE create_file
(loc_in IN varchar2, file_in IN varchar2, line_in IN varchar2 :=null)
IS
file_handle utl_file.file_type;
BEGIN
file_handle := utl_file.fopen (loc_in, file_in, 'W');
IF line_in IS NOT NULL THEN
utl_file.put_line(file_handle, line_in);
ELSE
utl_file.put_line(file_handle, 'Nothing to write');
END IF;
utl_file.fclose(file_handle);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
dbms_output.put_line('Error in creating log file');
 
END;
/

3.2.9 execute_dml_statement

CREATE or REPLACE procedure execute_dml_statement
(
p_statement_txt in varchar2
)
IS
pragma AUTONOMOUS_TRANSACTION;
BEGIN
BEGIN
execute immediate p_statement_txt;
END;
END;
/

3.2.10 execute_statement

CREATE or REPLACE PROCEDURE execute_statement
(p_statement_txt1 varchar2,
param1 varchar2,
p_statement_txt2 varchar2,
param2 varchar2,
p_statement_txt3 varchar2)
IS
cursor_handle number:=DBMS_SQL.OPEN_CURSOR;
rows_processed number:=0;
statement_txt varchar2(500);
BEGIN
statement_txt := p_statement_txt1 ||param1||P_statement_txt2|| param2 ||p_statement_txt3;
dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE (cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor_handle) THEN
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
END IF;
END execute_statement;
/

3.2.11 Login_Disable

ユーザが一定期間ログインしない場合、Login_Disable プロシージャはそのユーザを無効にします。

CREATE OR REPLACE PROCEDURE Login_Disable
IS
Baseline date;
difference number;
 
CURSOR usertable IS
SELECT * FROM USER_TABLE;
 
BEGIN
for rec in usertable loop
if rec.AUTODISABLEINTERVAL <> 0 then
if rec.LASTLOGINTIME is NULL then
Baseline := rec.PASSWORDSETTIME;
else
Baseline := rec.LASTLOGINTIME;
end if;
 
difference := sysdate - Baseline;
 
if (difference >= rec.AUTODISABLEINTERVAL) then
update user_table set USERLOGINDISABLED = 1 where userid = rec.userid;
commit;
END IF;
END IF;
END LOOP;
END Login_Disable;
/

3.2.12 PortName

CREATE or REPLACE PROCEDURE PortName
(p_nedbaccessid IN number,
p_physicalloc IN number,
p_ifindex IN number,
p_moduletype IN number,
p_objectindex IN number,
p_portname OUT varchar2)
IS
o_portname varchar2(256);
BEGIN
 
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND ifindex=p_ifindex
AND moduleType=p_moduletype
AND objectindex=p_objectindex;
 
p_portname := o_portname;
 
EXCEPTION
WHEN TOO_MANY_ROWS
THEN null;
 
END PortName;
/

3.2.13 prune_ne

create or replace procedure prune_ne
(p_nesysid IN varchar2)
IS
p_nedbaccessid number;
p_nenodeid number;
prune_state number:=0;
prune_process_state number :=0;
counter number:=0;
rows_deleted number:=3000;
rows_processed number:=0;
rows_deleted_total number:=0;
cursor_handle INTEGER ;
statement_txt varchar2(500);
prune_date varchar2(30);
ORACLE_SID varchar2(20);
 
CURSOR IsGne(p_nesysid IN ne_info_table.nesysid%TYPE) IS
SELECT gneid
FROM gne_table
WHERE gnesysid=p_nesysid;
r_gneid ne_info_table.gneid%TYPE;
 
INVALID_NESYSID EXCEPTION;
PRAGMA EXCEPTION_INIT (INVALID_NESYSID, -20003);
 
PRUNE_FAILED EXCEPTION;
PRAGMA EXCEPTION_INIT (PRUNE_FAILED, -20004);
 
BEGIN
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
OPEN IsGne(p_nesysid);
FETCH IsGne INTO r_gneid;
IF IsGne%FOUND THEN
dbms_output.put_line('This is a GNE , check if it has children');
SELECT count(*) INTO counter
FROM ne_info_table
WHERE gneid=r_gneid ;
 
 
IF (counter > 1 ) THEN
dbms_output.put_line('This GNE has the following Children.');
FOR rec IN (SELECT nesysid FROM ne_info_table
WHERE gneid=r_gneid and nesysid <> p_nesysid ) LOOP
dbms_output.put_line('NE: '||rec.nesysid);
END LOOP;
dbms_output.put_line('Can not delete a GNE that has children!');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Can not delete a GNE that has children!');
prune_process_state :=1;
END IF;
 
END IF;
CLOSE IsGne;
 
IF (prune_process_state=0) THEN
dbms_output.put_line('process prune this nesysid');
SELECT to_char(sysdate,'MM/DD/YYYY HH24:MI:SS') INTO prune_date FROM dual;
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Process prune '||p_nesysid||' at '||prune_date);
 
 
SELECT nedbaccessid, nenodeid INTO p_nedbaccessid, p_nenodeid
FROM ne_info_table
WHERE nesysid=p_nesysid;
 
FOR i IN ( SELECT a.table_name,a.column_name
FROM user_tab_columns a,
user_objects b
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
AND (
(a.column_name like 'NEDBACCESSID%' and a.column_name != 'NEDBACCESSIDCOLINDB') OR
(a.column_name like '%NODE_ID%' and a.table_name like '%_DATA') OR
(a.column_name like 'NODE_ID%' and a.table_name
IN (
'SCMNODE',
'SCMENABLELIST',
'COLL_ERR_LOG',
'COLL_INFO',
'COLL_INFO',
'COLL_INFO',
'COLL_SUMM_LIST',
'COMP_FILE_LIST',
'DESTROYNODE',
'FILE_ERR_LOG',
'FILE_INFO',
'FILE_QUEUE_LOG',
'FILE_TRANSFER_LOG',
'PEND_FILE_LIST',
'SCMCARDCOLL',
'SCMCARDCOLLHOST',
'SCMCARDCOLLSTATUS',
'SCMCARDENABLE',
'SCMDB_NODE_INFO',
'SCMENABLELIST',
'SCMENABLESUBTYPE',
'SCMNODE',
'SCMNODECOLL',
'SCMNODECOLLHOST',
'SCMNODECOLLSTATUS',
'SCMNODEENABLE',
'SYNC_INFO',
'SYNC_LIST'
)
) OR
a.column_name='CKTNODEID' OR
a.column_name='CHILDID' OR
a.column_name='GROUPORNEID')
)
LOOP
 
SELECT decode(i.table_name,'NE_INFO_TABLE' ,1,
'PURGED_NE_TABLE' ,1,
'USER_NE_TABLE' ,1,
0) INTO prune_state FROM dual;
IF (prune_state = 0 ) THEN
rows_deleted_total :=0;
cursor_handle := DBMS_SQL.OPEN_CURSOR;
 
IF (i.table_name='ACTIVE_ALARM_TABLE') THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where nedbaccessid = '||p_nedbaccessid ||
' OR (nedbaccessid=0 and activealarmtype not in (5003,5012) AND ModuleOrIfIndex='||p_nedbaccessid||' )
AND rownum < = '||rows_deleted;
END IF;
 
IF (i.column_name like 'NEDBACCESSID%' and i.table_name<>'ACTIVE_ALARM_TABLE') THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where '||i.column_name ||' = '||p_nedbaccessid ||
' AND rownum < = '||rows_deleted;
END IF;
IF (i.column_name like '%NODE_ID%' and i.table_name<>'ACTIVE_ALARM_TABLE') THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where '||i.column_name ||' = '||p_nedbaccessid ||
' AND rownum < = '||rows_deleted;
END IF;
-- purge all circuit tables based on cktnodeid
 
IF (i.column_name='CKTNODEID' ) THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where cktnodeid = '||p_nenodeid ||
' AND rownum < = '||rows_deleted;
END IF;
 
 
IF (i.column_name='CHILDID') THEN
statement_txt :='DELETE FROM '||i.table_name||
' WHERE childtype=3 AND childid = '||p_nedbaccessid||
' AND rownum < = '||rows_deleted;
END IF;
 
-- this is user_map_table
 
IF (i.column_name='GROUPORNEID') THEN
statement_txt := 'DELETE FROM '||i.table_name ||
' WHERE treenodetype=3 AND grouporneid = '||p_nedbaccessid||
' AND rownum <= '||rows_deleted;
END IF;
--append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','*** Executing { '|| statement_txt || ' }');
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
LOOP
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
commit;
IF rows_processed=0 THEN
exit;
END IF;
END LOOP;
 
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
 
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||rows_deleted_total||' from '||i.table_name);
 
END IF;
END LOOP;
 
counter:=0;
IF ( p_nenodeid != 0 ) THEN
FOR rec IN ( SELECT rowid,cktnodeid,cktuniqueid FROM CIRCUIT_DEST_TBL
WHERE CktDestNodeId=p_nenodeid)
LOOP
DELETE FROM CIRCUIT_DEST_TBL
WHERE rowid= rec.rowid;
 
UPDATE circuit_tbl
SET CktState=4
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
AND CktState != 16;
 
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from CIRCUIT_DEST_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from CIRCUIT_DEST_TBL');
 
counter:=0;
FOR rec IN ( SELECT rowid,cktnodeid, cktuniqueid FROM CIRCUIT_SPAN_TBL
WHERE CktSpanSrcNodeId=p_nenodeid
OR CktSpanDestNodeId=p_nenodeid)
LOOP
DELETE FROM CIRCUIT_SPAN_TBL
WHERE rowid=rec.rowid;
 
UPDATE circuit_tbl
SET cktstate=4
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
AND cktstate != 16;
 
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from CIRCUIT_SPAN_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from CIRCUIT_SPAN_TBL');
END IF;
counter:=0;
FOR rec IN ( SELECT rowid FROM ONS155XX_GRANULAR_CC_TBL
WHERE GCCSrcNodeId=p_nedbaccessid
OR GCCDestNodeId=p_nedbaccessid)
LOOP
DELETE FROM ONS155XX_GRANULAR_CC_TBL
WHERE rowid=rec.rowid;
 
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from ONS155XX_GRANULAR_CC_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from ONS155XX_GRANULAR_CC_TBL');
 
counter:=0;
FOR rec IN ( SELECT rowid,cktnodeid, cktuniqueid FROM ONS155XX_CIRCUIT_CC_TBL
WHERE CktCCNodeId=p_nedbaccessid )
LOOP
DELETE FROM ONS155XX_CIRCUIT_CC_TBL
WHERE rowid=rec.rowid;
 
UPDATE circuit_tbl
SET cktstate=4
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
AND cktstate != 16;
 
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from ONS155XX_CIRCUIT_CC_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from ONS155XX_CIRCUIT_CC_TBL');
 
counter:=0;
FOR rec IN ( SELECT rowid FROM ONS155XX_PATH_TBL
WHERE PathSrcNodeId=p_nedbaccessid
OR PathDestNodeId=p_nedbaccessid)
LOOP
DELETE FROM ONS155XX_PATH_TBL
WHERE rowid=rec.rowid;
 
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from ONS155XX_PATH_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from ONS155XX_PATH_TBL');
 
 
counter:=0;
FOR rec IN ( SELECT rowid FROM link_table
WHERE linksrcnode=p_nedbaccessid OR
linkdstnode=p_nedbaccessid)
LOOP
DELETE FROM link_table
WHERE rowid = rec.rowid;
counter := counter+1;
IF mod(counter,300) = 0 THEN
commit;
END IF;
END LOOP;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from link_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from link_table');
 
 
 
counter := 0;
DELETE from ne_info_table
WHERE nedbaccessid=p_nedbaccessid;
counter := counter+1;
commit;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from ne_info_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Deleted rows committed '||counter||' from ne_info_table');
 
DELETE from gne_table
WHERE gnesysid=p_nesysid;
commit;
 
prune_date:=to_char(sysdate,'MM/DD/YYYY HH24:MI:SS');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','prune '||p_nesysid||' is finished successfully at '||prune_date);
END IF;
 
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No such network element');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','No such network element');
raise INVALID_NESYSID;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
DBMS_OUTPUT.PUT_LINE(SQLCODE);
DBMS_OUTPUT.PUT_LINE('Error in pruning NE!');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Error in pruning NE!'||SQLERRM||','||SQLCODE);
raise PRUNE_FAILED;
END;
/

3.2.14 prune_pm

3.2.14.1 小規模構成用の prune_pm プロシージャ

Create or replace procedure prune_pm (
intervaldays IN number,
is24h_flag IN number default(2)
)
IS
counter number := 0;
rows_processed number := 0;
cursor_handle integer;
cursor_handle1 integer;
cursor_handle2 integer;
statement_txt varchar2(500);
prunedate date;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rowid_tab_v rowid_tab;
rows_to_be_deleted number := 100000;
rows_deleted_total number := 0;
sec_convertor number :=86400;
table_name varchar2(127);
days number := 0;
 
ORACLE_SID varchar2(20);
LOGDIR varchar2(80);
LOGFILE varchar2(40);
 
BEGIN
 
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
LOGDIR := '/oraclesw9i/admin/' || ORACLE_SID || '/udump';
 
if ( is24h_flag = 0 ) then
LOGFILE := 'prune_15min_pm.log';
elsif ( is24h_flag = 1 ) then
LOGFILE := 'prune_1day_pm.log';
elsif ( is24h_flag = 2 ) then
LOGFILE := 'prune_both_pm.log';
else
LOGFILE := 'prune_pm.log';
end if;
 
IF ( intervaldays != -1) THEN
prunedate:=sysdate-intervaldays;
dbms_output.put_line('prune data before '||prunedate);
create_file(LOGDIR, LOGFILE,'Starting prune pm at '||sysdate);
append_file(LOGDIR, LOGFILE,'prune pm data before '||prunedate);
rows_processed:=0;
 
if (is24h_flag = 0) then
append_file(LOGDIR, LOGFILE,'pruning "15min" pm data only at '||sysdate);
elsif (is24h_flag = 1) then
append_file(LOGDIR, LOGFILE,'pruning "1day" pm data only at '||sysdate);
else
append_file(LOGDIR, LOGFILE,'pruning both "15min" and "1day" pm data at '||sysdate);
end if;
----- MGX8880 PM {
-- delete entries in data tables
FOR i IN ( SELECT a.table_name,a.column_name
FROM user_tab_columns a,
user_objects b
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
AND (a.column_name like '%TIMESTAMP%' and a.table_name like '%_DATA')
)
LOOP
rows_deleted_total :=0;
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'DELETE FROM '||i.table_name ||' WHERE '||i.column_name ||' < ' ||sec_convertor|| '*(to_date(' ||
'''' || prunedate || '''' || ', ' || '''' || 'mm/dd/yyyy hh24:mi:ss' ||
'''' || ') - to_date(' || '''' || '01/01/1970 00:00:00' ||
'''' || ', ' || '''' || 'mm/dd/yyyy hh24:mi:ss' || '''' || '))'
|| ' AND rownum <= '||rows_to_be_deleted;
append_file(LOGDIR,LOGFILE,'*** Executing { '|| statement_txt || ' }');
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
LOOP
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
commit;
--IF rows_processed=0 THEN
exit;
--END IF;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'Deleted '||rows_deleted_total||' rows from '||i.table_name || ' at '||sysdate );
 
END LOOP;
 
--- drop entire tables for scaling tables
DECLARE CURSOR cursor_frags IS
SELECT object_name, to_date ( sysdate, 'mm/dd/yyyy hh24:mi:ss' ) - to_date (substr(object_name, length(object_name) - 7, 8), 'yymmddhh24')
FROM user_objects
WHERE object_name like '%_DATA_________' AND object_type = 'TABLE';
BEGIN
 
OPEN cursor_frags;
LOOP
FETCH cursor_frags INTO table_name, days;
EXIT WHEN cursor_frags%NOTFOUND;
append_file(LOGDIR,LOGFILE,'*** Fetch table_name = '|| table_name || ' days = ' || days);
IF (days > intervaldays) THEN
rows_deleted_total :=0;
cursor_handle1 := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'DROP TABLE '|| table_name;
append_file(LOGDIR,LOGFILE,'*** Executing { '|| statement_txt || ' }');
DBMS_SQL.PARSE(cursor_handle1, statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle1);
commit;
DBMS_SQL.CLOSE_CURSOR (cursor_handle1);
 
append_file(LOGDIR,LOGFILE,'Dropped ' || table_name || ' at '||sysdate );
 
rows_deleted_total :=0;
cursor_handle2 := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'DELETE FROM scmfragdatatables WHERE data_table_name = '|| '''' || table_name || '''';
append_file(LOGDIR,LOGFILE,'*** Executing { '|| statement_txt || ' }');
DBMS_SQL.PARSE(cursor_handle2, statement_txt, DBMS_SQL.NATIVE);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle2);
commit;
DBMS_SQL.CLOSE_CURSOR (cursor_handle2);
append_file(LOGDIR,LOGFILE,'Deleted from scmfragdatatables - ' || table_name || ' at '||sysdate );
END IF;
END LOOP;
CLOSE cursor_frags;
END;
----- }
 
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_ds3_pm_table
where timestamp < prunedate and rownum <= rows_to_be_deleted
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_ds3_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
 
END LOOP;
else
FOR i IN (select rowid from ons15454_ds3_pm_table
where timestamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_ds3_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
 
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ons15454_ds3_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ons15454_DS3_PM_table at '||sysdate );
 
counter:=0;
rows_processed:=0;
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_sonet_path_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_path_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ons15454_sonet_path_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_path_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_path_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_SONET_PATH_PM_TABLE at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_sonet_line_pm_table
where timestamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_line_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ons15454_sonet_line_pm_table
where timestamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_line_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_line_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_SONET_LINE_PM_TABLE at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_sonet_sec_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_sec_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ons15454_sonet_sec_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_sec_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ons15454_sonet_sec_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_SONET_SEC_PM_TABLE at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_enet_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_enet_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ons15454_enet_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_enet_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ons15454_enet_pm_table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_ENET_PM_TABLE at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ons15454_ds1_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_DS1_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ons15454_ds1_pm_table
where timestamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_DS1_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_DS1_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_DS1_PM_TABLE at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_Sonet_VT_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_Sonet_VT_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_Sonet_VT_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_Sonet_VT_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_Sonet_VT_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_Sonet_VT_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_RS_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_RS_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_RS_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_MS_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_MS_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_MS_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_HO_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_HO_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_HO_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_LO_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_LO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_LO_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_LO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_LO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_LO_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_E1_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E1_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_E1_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E1_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E1_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_E1_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_E3_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E3_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_E3_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E3_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E3_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_E3_PM_Table at '||sysdate);
 
counter :=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454SDH_E4_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E4_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454SDH_E4_PM_Table
where TimeStamp < prunedate AND rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E4_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
commit;
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454SDH_E4_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454SDH_E4_PM_Table at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155XX_SONET_SEC_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155XX_SONET_SEC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS155XX_SONET_SEC_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155XX_SONET_SEC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS155XX_SONET_SEC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155XX_SONET_SEC_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155xx_Phy_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Phy_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS155xx_Phy_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Phy_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Phy_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155xx_Phy_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155xx_Opt_Power_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
null;
FOR i IN (select rowid from ONS155xx_Opt_Power_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS155xx_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155xx_Opt_Power_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15501_Opt_Power_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15501_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15501_Opt_Power_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15501_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS15501_Opt_Power_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15501_Opt_Power_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155xx_CDL_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_CDL_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS155xx_CDL_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_CDL_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS155xx_CDL_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155xx_CDL_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155xx_Ether_Hist_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Ether_Hist_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS155xx_Ether_Hist_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_Ether_Hist_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS155xx_Ether_Hist_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155xx_Ether_Hist_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS155xx_FCM_PE_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_FCM_PE_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS155xx_FCM_PE_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and interval = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS155xx_FCM_PE_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1. .. counter
DELETE FROM ONS155xx_FCM_PE_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS155xx_FCM_PE_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter := 0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_IOC_W_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_IOC_W_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_IOC_W_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_IOC_W_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_IOC_W_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_IOC_W_PM_TABLE at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter :=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_TRANSPONDER_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted ) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_TRANSPONDER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_TRANSPONDER_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_TRANSPONDER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_TRANSPONDER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_TRANSPONDER_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_LSM_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LSM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_LSM_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LSM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LSM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_LSM_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_SCF_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_SCF_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_SCF_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
commit;
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_SCF_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_SCF_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_SCF_PM_TABLE at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_AMPLIFIER_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_AMPLIFIER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_AMPLIFIER_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_AMPLIFIER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_AMPLIFIER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_AMPLIFIER_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_WD_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_WD_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_WD_PM_TABLE at '|| sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_OADM_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OADM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_OADM_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OADM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OADM_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_OADM_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_WD_RX_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_RX_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_WD_RX_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_RX_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_WD_RX_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_WD_RX_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_OSU_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OSU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_OSU_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OSU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OSU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
exit;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_OSU_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_BCS_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_BCS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_BCS_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_BCS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_BCS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_BCS_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_OAD_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OAD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_OAD_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OAD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_OAD_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_OAD_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS158XX_CMP_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_CMP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS158XX_CMP_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_CMP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_CMP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS158XX_CMP_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600_Sonet_Sec_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Sec_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600_Sonet_Sec_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Sec_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Sec_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600_Sonet_Sec_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600_Sonet_Line_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Line_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600_Sonet_Line_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Line_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Line_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600_Sonet_Line_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600_Sonet_Path_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Path_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600_Sonet_Path_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Path_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600_Sonet_Path_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600_Sonet_Path_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_PHY_LAYER_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_PHY_LAYER_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_PHY_LAYER_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_PHY_LAYER_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_PHY_LAYER_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_PHY_LAYER_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_POS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_POS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_POS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_POS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_POS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_POS_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_OTN_SEC_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_SEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_OTN_SEC_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_SEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_SEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_OTN_SEC_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_OTN_PATH_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_PATH_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_OTN_PATH_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_PATH_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_PATH_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_OTN_PATH_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15454_OTN_FEC_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_FEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15454_OTN_FEC_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_FEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15454_OTN_FEC_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15454_OTN_FEC_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600SDH_RS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600SDH_RS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_RS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600SDH_RS_PM_Table at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600SDH_MS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600SDH_MS_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_MS_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600SDH_MS_PM_Table at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS15600SDH_HO_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS15600SDH_HO_PM_Table
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS15600SDH_HO_PM_Table
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS15600SDH_HO_PM_Table at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS1530x_RS_PM_TABLE
where TimeStamp< prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_RS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS1530x_RS_PM_TABLE
where TimeStamp< prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_RS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_RS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS1530x_RS_PM_TABLE at '||sysdate);
 
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS1530x_MS_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_MS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS1530x_MS_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_MS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_MS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS1530x_MS_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS1530x_HO_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_HO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS1530x_HO_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_HO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_HO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS1530x_HO_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS1530x_LO_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_LO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS1530x_LO_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_LO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_LO_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS1530x_LO_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from ONS1530x_IP_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_IP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from ONS1530x_IP_PM_TABLE
where TimeStamp < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_IP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS1530x_IP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
 
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from ONS1530x_IP_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_INTERFACE_GC_PM_TABLE
where INTERFACEGCTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_GC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_INTERFACE_GC_PM_TABLE
where INTERFACEGCTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_GC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_GC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_INTERFACE_GC_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_INTERFACE_DRC_PM_TABLE
where INTERFACEDRCTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_DRC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_INTERFACE_DRC_PM_TABLE
where INTERFACEDRCTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_DRC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_INTERFACE_DRC_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_INTERFACE_DRC_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_BGP_PEER_PM_TABLE
where BGPPEERTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_BGP_PEER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_BGP_PEER_PM_TABLE
where BGPPEERTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_BGP_PEER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_BGP_PEER_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_BGP_PEER_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_NODE_CPU_PM_TABLE
where NODECPUTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_CPU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_NODE_CPU_PM_TABLE
where NODECPUTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_CPU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_CPU_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_NODE_CPU_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_NODE_MEMORY_PM_TABLE
where NODEMEMORYTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_MEMORY_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_NODE_MEMORY_PM_TABLE
where NODEMEMORYTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_MEMORY_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_MEMORY_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_NODE_MEMORY_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_NODE_PROCESS_PM_TABLE
where NODEPROCESSTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_PROCESS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_NODE_PROCESS_PM_TABLE
where NODEPROCESSTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_PROCESS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_NODE_PROCESS_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_NODE_PROCESS_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_MPLS_TE_LINK_PM_TABLE
where MPLSTELINKTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_LINK_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_MPLS_TE_LINK_PM_TABLE
where MPLSTELINKTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_LINK_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_LINK_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_MPLS_TE_LINK_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_MPLS_TE_TUNNEL_PM_TABLE
where MPLSTETUNNELTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_TUNNEL_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_MPLS_TE_TUNNEL_PM_TABLE
where MPLSTETUNNELTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_TUNNEL_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_TE_TUNNEL_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_MPLS_TE_TUNNEL_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_MPLS_INTERFACE_PM_TABLE
where MPLSINTERFACETIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_INTERFACE_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_MPLS_INTERFACE_PM_TABLE
where MPLSINTERFACETIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_INTERFACE_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_INTERFACE_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_MPLS_INTERFACE_PM_TABLE at '||sysdate);
 
counter:=0;
rows_processed:=0;
LOOP
counter:=0;
 
if (is24h_flag = 2) then
FOR i IN (select rowid from HFR_MPLS_LDP_PM_TABLE
where MPLSLDPTIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_LDP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
else
FOR i IN (select rowid from HFR_MPLS_LDP_PM_TABLE
where MPLSLDPTIMESTAMP < prunedate and rownum <= rows_to_be_deleted
and is24h = is24h_flag
) LOOP
counter := counter + 1;
rowid_tab_v(counter) := i.rowid;
 
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_LDP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
END IF;
END LOOP;
end if;
 
IF counter < rows_to_be_deleted THEN
IF counter > 0 THEN
FORALL rid IN 1 .. counter
DELETE FROM HFR_MPLS_LDP_PM_TABLE
WHERE rowid = rowid_tab_v(rid);
COMMIT;
rows_processed:=rows_processed+counter;
counter := 0;
END IF;
EXIT;
END IF;
 
END LOOP;
append_file(LOGDIR, LOGFILE,'Deleted '||rows_processed||' rows from HFR_MPLS_LDP_PM_TABLE at '||sysdate);
 
ELSE
dbms_output.put_line('The user choose to keep all the data, so no prune at this time');
create_file(LOGDIR, LOGFILE,'User choose to keep all the data, no prune');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('something is wrong');
create_file(LOGDIR, 'prune_pm.err','Error in pruning pm '||SQLERRM||', '||SQLCODE);
END prune_pm;
 
/
 

3.2.14.2 中規模、大規模およびハイエンド構成用の prune_pm プロシージャ

create or replace procedure Prune_pm (
intervaldays in number,
is24h_flag in number default(2)
)
AS
partition_to_be_pruned varchar2(9);
cursor_handle integer;
cursor_handle_1 integer;
statement_txt varchar2(500);
statement_txt_1 varchar2(500);
rows_processed number := 0;
rows_processed_1 number :=0;
rows_deleted_total number := 0;
rows_to_be_deleted number := 100000;
 
prunedate date;
deleted_rows number;
ORACLE_SID varchar2(20);
p_partition_name varchar(30);
p_15min_subpartition_name varchar(30);
p_1day_subpartition_name varchar(30);
 
LOGDIR varchar2(80);
LOGFILE varchar2(40);
BEGIN
dbms_output.enable;
SELECT activevalue INTO ORACLE_SID
FROM ctm_config_table
WHERE sectionname='database' and propertyname='dbname';
 
IF ( intervaldays != -1) THEN
prunedate := sysdate-intervaldays;
 
LOGDIR := '/oraclesw9i/admin/' || ORACLE_SID || '/udump';
 
if ( is24h_flag = 0 ) then
LOGFILE := 'prune_15min_pm.log';
elsif ( is24h_flag = 1 ) then
LOGFILE := 'prune_1day_pm.log';
elsif ( is24h_flag = 2 ) then
LOGFILE := 'prune_both_pm.log';
else
LOGFILE := LOGFILE;
end if;
 
dbms_output.put_line('creating file: ' || LOGDIR||'/'||LOGFILE);
 
create_file(LOGDIR,LOGFILE,'Starting prune pm at '||sysdate);
append_file(LOGDIR,LOGFILE,'prune pm data before '||prunedate);
 
--prunedate:= trunc(sysdate-intervaldays);
 
if (is24h_flag = 0) then
append_file(LOGDIR,LOGFILE,'pruning "15min" pm data only at '||sysdate);
elsif (is24h_flag = 1) then
append_file(LOGDIR,LOGFILE,'pruning "1day" pm data only at '||sysdate);
else
append_file(LOGDIR,LOGFILE,'pruning both "15min" and "1day" pm data at '||sysdate);
end if;
 
----- MGX8880 PM {
FOR i IN ( SELECT a.table_name,a.column_name
FROM user_tab_columns a,
user_objects b
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
AND (a.column_name like '%TIMESTAMP%' and a.table_name like '%_DATA')
)
LOOP
rows_deleted_total :=0;
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'DELETE FROM '||i.table_name ||' WHERE '||i.column_name ||' < (to_date(' ||
'''' || prunedate || '''' || ', ' || '''' || 'mm/dd/yyyy hh24:mi:ss' ||
'''' || ') - to_date(' || '''' || '01/01/1970 00:00:00' ||
'''' || ', ' || '''' || 'mm/dd/yyyy hh24:mi:ss' || '''' || '))'
|| ' AND rownum <= '||rows_to_be_deleted;
--append_file(LOGDIR,LOGFILE,'*** Executing { '|| statement_txt || ' }');
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
LOOP
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
commit;
--IF rows_processed=0 THEN
exit;
--END IF;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'Deleted '||rows_deleted_total||' rows from '||i.table_name || ' at '||sysdate );
 
END LOOP;
----- }
 
FOR rec IN ( SELECT table_name, index_name,column_name FROM user_ind_columns
WHERE table_name like '%PM_TABLE'
and table_name !='ONS158XX_TIMESTAMP_PM_TABLE'
AND column_name like '%TIMESTAMP%'
AND column_position=1)
LOOP
DBMS_OUTPUT.PUT_LINE('table: ' || rec.table_name);
 
cursor_handle_1 := DBMS_SQL.OPEN_CURSOR;
statement_txt_1 := 'SELECT count(rowid) FROM '||rec.table_name||' where '||rec.column_name ||'<= '||''''||prunedate||'''';
if (is24h_flag != 2) then
if (substr(rec.table_name, 1, 6) != 'ONS155') then
statement_txt_1 := statement_txt_1 || ' and is24h=' ||is24h_flag;
else
statement_txt_1 := statement_txt_1 || ' and interval=' ||is24h_flag;
end if;
end if;
--DBMS_OUTPUT.PUT_LINE(statement_txt_1);
DBMS_SQL.PARSE(cursor_handle_1, statement_txt_1, DBMS_SQL.NATIVE);
 
DBMS_SQL.DEFINE_COLUMN ( cursor_handle_1,1, deleted_rows);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle_1);
IF DBMS_SQL.FETCH_ROWS(cursor_handle_1)=0 then
EXIT;
ELSE
DBMS_SQL.COLUMN_VALUE (cursor_handle_1,1, deleted_rows);
deleted_rows :=nvl(deleted_rows,0);
append_file(LOGDIR,LOGFILE,'pruned '||deleted_rows||' from '||rec.table_name);
END IF;
DBMS_SQL.CLOSE_CURSOR (cursor_handle_1);
 
if (is24h_flag = 2) then
FOR i IN ( SELECT partition_name FROM user_tab_partitions
--Where to_date(substr(partition_name,2,9)) <= prunedate
Where to_date(substr(partition_name,2,9)) <= (select trunc(prunedate) from dual)
AND table_name=rec.table_name)
LOOP
--dbms_output.put_line(rec.table_name||', '||i.partition_name||', '||to_date(substr(i.partition_name,2,9)));
dbms_output.put_line(i.partition_name);
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop partition '||i.partition_name;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'dropped partition '||i.partition_name||' from '||rec.table_name);
END LOOP;
elsif (is24h_flag = 0) then --15min
FOR i IN (
SELECT a.partition_name,
a.subpartition_name p15min_sp,
(select b.subpartition_name from user_tab_subpartitions b
where b.table_name = a.table_name
and b.subpartition_name like upper('p1day_%')
and substr(b.subpartition_name, 7, 14) = substr(a.subpartition_name, 8, 15)) as p1day_sp
FROM user_tab_subpartitions a
where a.table_name = rec.table_name
and to_date(substr(a.partition_name,2,9)) <= (select trunc(prunedate) from dual)
and a.subpartition_name like upper('p15min_%')
)
LOOP
--DBMS_OUTPUT.PUT_LINE(rec.table_name ||', ' || i.p15min_sp ||', ' || i.p1day_sp);
if(i.p1day_sp is null) then
--drop partition
--dbms_output.put_line('drop partition ' || i.partition_name);
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop partition '||i.partition_name;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'dropped partition '||i.partition_name||' from '||rec.table_name);
else
--drop subpartition p15min_sp only
--dbms_output.put_line('drop subpartition ' || i.p15min_sp);
 
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop subpartition '||i.p15min_sp;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'dropped subpartition '||i.p15min_sp||' from '||rec.table_name);
end if;
END LOOP;
else --is24h_flag=1 for 1day
FOR i IN (
SELECT a.partition_name,
a.subpartition_name p1day_sp,
(select b.subpartition_name from user_tab_subpartitions b
where b.table_name = a.table_name
and b.subpartition_name like upper('p15min_%')
and substr(b.subpartition_name, 8, 15) = substr(a.subpartition_name, 7, 14)) as p15min_sp
FROM user_tab_subpartitions a
where a.table_name = rec.table_name
and to_date(substr(a.partition_name,2,9)) <= (select trunc(prunedate) from dual)
and a.subpartition_name like upper('p1day_%')
)
LOOP
--DBMS_OUTPUT.PUT_LINE(rec.table_name ||', ' || i.p15min_sp ||', ' || i.p1day_sp);
if(i.p15min_sp is null) then
--drop partition
--dbms_output.put_line('drop partition ' || i.partition_name);
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop partition '||i.partition_name;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'dropped partition '||i.partition_name||' from '||rec.table_name);
else
--drop subpartition p1day_sp only
--dbms_output.put_line('drop subpartition ' || i.p1day_sp);
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'alter table '||rec.table_name ||' drop subpartition '||i.p1day_sp;
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'dropped subpartition '||i.p1day_sp||' from '||rec.table_name);
end if;
END LOOP;
end if;
END LOOP;
append_file(LOGDIR,LOGFILE,'prune pm successfully finished at '||sysdate);
END IF;
EXCEPTION
WHEN OTHERS THEN
create_file(LOGDIR,'prune_pm.err','Error in pruning pm log '||SQLERRM||', '||SQLCODE);
 
END;
/

3.2.15 reset_seq

CTM では、reset_seq ストアド プロシージャを使用して、移行時にシーケンス番号のドロップと再生成を行います。

CREATE or REPLACE PROCEDURE reset_seq
(p_statement_txt1 varchar2,
seq_name varchar2,
p_statement_txt2 varchar2,
seq_number number)
IS
cursor_handle number:=DBMS_SQL.OPEN_CURSOR;
rows_processed number:=0;
statement_txt varchar2(500);
BEGIN
statement_txt := p_statement_txt1 ||' '||seq_name||P_statement_txt2||' '||seq_number;
dbms_output.put_line(statement_txt);
DBMS_SQL.PARSE (cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor_handle) THEN
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
END IF;
RAISE;
END reset_seq;
/

3.2.16 update_portnames

create or replace procedure update_portnames ( NEDBPARAM eqpt_info_table.NEDBACCESSID%TYPE,objindx eqpt_info_table.objectindex%TYPE
) is
nenodeid2 number(10);
BEGIN
select nenodeid into nenodeid2
from ne_info_table
where nedbaccessid=nedbparam;
 
for rec in(select PHYSICALLOC,col200 from eqpt_info_table where NEDBACCESSID
= NEDBPARAM and objectindex=objindx) LOOP
 
 
update circuit_tbl
set CKTSRCPORTNAME= rec.col200
where CKTSRCNODEID=nenodeid2
and CKTSRCPHYSICALLOC=rec.PHYSICALLOC
and nvl(CKTSRCPORTNAME,'#^*') != nvl(rec.col200,'*##')
and ((CKTSRCPORTNAME is not null and rec.col200 is null)
or
(CKTSRCPORTNAME is null and rec.col200 is not null));
commit;
 
update circuit_tbl
set CKTSECSRCPORTNAME= rec.col200
where CKTSECSRCNODEID=nenodeid2
and CKTSECSRCPHYSICALLOC=rec.PHYSICALLOC
and nvl(CKTSECSRCPORTNAME,'#^*') != nvl(rec.col200,'*##')
and ((CKTSECSRCPORTNAME is not null and rec.col200 is null)
or
(CKTSECSRCPORTNAME is null and rec.col200 is not null));
 
commit;
 
update circuit_dest_tbl
set CKTDESTPORTNAME= rec.col200
where CKTDESTNODEID=nenodeid2
and CKTDESTPHYSICALLOC=rec.PHYSICALLOC
and nvl(CKTDESTPORTNAME,'#^*') !=nvl(rec.col200,'*##')
and ((CKTDESTPORTNAME is not null and rec.col200 is null)
or
(CKTDESTPORTNAME is null and rec.col200 is not null));
 
 
update circuit_span_tbl
set CKTSPANSRCPORTNAME= rec.col200
where CKTSPANSRCNODEID=nenodeid2
and CKTSPANSRCPHYSICALLOC=rec.PHYSICALLOC
and nvl(CKTSPANSRCPORTNAME,'#^*') !=nvl(rec.col200,'*##')
and ((CKTSPANSRCPORTNAME is not null and rec.col200 is null)
or
(CKTSPANSRCPORTNAME is null and rec.col200 is not null));
 
update circuit_span_tbl
set CKTSPANDESTPORTNAME= rec.col200
where CKTSPANDESTNODEID=nenodeid2
and CKTSPANDESTPHYSICALLOC=rec.PHYSICALLOC
and nvl(CKTSPANDESTPORTNAME,'#^*') != nvl(rec.col200,'*##')
and ((CKTSPANDESTPORTNAME is not null and rec.col200 is null)
or
(CKTSPANDESTPORTNAME is null and rec.col200 is not null));
 
 
commit;
 
END LOOP;
 
END;
/

3.3 CTM の関数

この項では、CTM で使用される関数の内容を示します。関数はパラメータを読み取り、値を返します。関数はアルファベット順に示されています。

3.3.1 collapseddestnodename

CREATE or replace function collapseddestnodename(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktdestnodename is
select CktDestNodeId
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktDestNodeId is not null;
finaldestNode varchar2(10000);
DestNedbaccessid varchar2(1000);
BEGIN
 
for rec in cktdestnodename loop
SELECT nedbaccessid INTO DestNedbaccessid
FROM ne_info_table
WHERE nenodeid= rec.CktDestNodeId and rec.CktDestNodeId != 0 ;
 
if cktdestnodename%ROWCOUNT = 1 then
finaldestNode:= DestNedbaccessid;
else
finaldestNode := finaldestNode||','||DestNedbaccessid;
end if;
end loop;
return finaldestNode;
END;
/

3.3.2 collapseddestnodename

CREATE or replace function collapseddestnodename (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktdestnodename is
select CktCtpNodeId
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type = 2
and CktCtpNodeId is not null;
finaldestNode varchar2(10000);
DestNedbaccessid varchar2(1000);
BEGIN
 
for rec in cktdestnodename loop
SELECT nedbaccessid INTO DestNedbaccessid
FROM ne_info_table
WHERE nenodeid= rec.CktCtpNodeId and rec.CktCtpNodeId != 0 ;
 
if cktdestnodename%ROWCOUNT = 1 then
finaldestNode:= DestNedbaccessid;
else
finaldestNode := finaldestNode||','||DestNedbaccessid;
end if;
end loop;
 
return finaldestNode;
 
END collapseddestnodename;
/

3.3.3 collapsedeqptportname

CREATE or replace function collapsedeqptportname(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor eqptcollpasedport is
select CktDestNodeId,
cktDestPhysicalloc,
cktDestIfindex,
cktdestModuleType
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktDestNodeId is not null
and cktDestPhysicalloc is not null
and cktDestIfindex is not null
and cktdestModuleType is not null;
 
finaleqptinfoport varchar2(10000);
DestNedbaccessid varchar2(1000);
BEGIN
 
for rec in eqptcollpasedport loop
SELECT nedbaccessid INTO DestNedbaccessid
FROM ne_info_table
WHERE nenodeid= rec.CktDestNodeId and rec.CktDestNodeId != 0;
 
if eqptcollpasedport%ROWCOUNT = 1 then
finaleqptinfoport:= '@'||eqptinfoport(DestNedbaccessid,rec.cktDestPhysicalloc,rec.cktDestIfindex, rec.cktdestModuleType);
else
finaleqptinfoport := finaleqptinfoport||','||'@'||eqptinfoport(DestNedbaccessid,rec.cktDestPhysicalloc,rec.cktDestIfindex, rec.cktdestModuleType);
end if;
end loop;
return finaleqptinfoport;
END;
/

3.3.4 collapsedifindex

CREATE or replace function collapsedifindex(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktobjectindexcursor is
select cktDestIfindex
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktDestIfindex is not null;
finalifindex varchar2(10000);
BEGIN
 
for rec in cktobjectindexcursor loop
if cktobjectindexcursor%ROWCOUNT = 1 then
finalifindex:= rec.cktDestIfindex;
else
finalifindex := finalifindex||','||rec.cktDestIfindex;
end if;
end loop;
return finalifindex;
END;
/

3.3.5 collapsedifindex

CREATE or replace function collapsedifindex (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktobjectindexcursor is
select CktCtpIfIndex
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type = 2
and CktCtpIfIndex is not null;
finalifindex varchar2(10000);
BEGIN
 
for rec in cktobjectindexcursor loop
if cktobjectindexcursor%ROWCOUNT = 1 then
finalifindex:= rec.CktCtpIfIndex;
else
finalifindex := finalifindex||','||rec.CktCtpIfIndex;
end if;
end loop;
 
return finalifindex;
 
END collapsedifindex;
/

3.3.6 collapsedmodeltype

CREATE or replace function collapsedmodeltype(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktmodeltype is
select cktDestModelType
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktDestModelType is not null;
finalphy varchar2(10000);
BEGIN
 
for rec in cktmodeltype loop
if cktmodeltype%ROWCOUNT = 1 then
finalphy:= rec.cktDestModelType;
else
finalphy := finalphy||','||rec.cktDestModelType;
end if;
end loop;
return finalphy;
END;

3.3.7 collapsedmodeltype

CREATE or replace function collapsedmodeltype (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktmodeltypecursor is
select CKTCTPMODELTYPE
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CTP_TYPE = 2
and CKTCTPMODELTYPE is not null;
 
finalmoduletype varchar2(10000);
BEGIN
 
for rec in cktmodeltypecursor loop
if cktmodeltypecursor%ROWCOUNT = 1 then
finalmoduletype:= rec.CKTCTPMODELTYPE;
else
finalmoduletype := finalmoduletype||','||rec.CKTCTPMODELTYPE;
end if;
end loop;
 
return finalmoduletype;
 
END collapsedmodeltype;
/

3.3.8 collapsedmodulename

CREATE or replace function collapsedmodulename(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return
varchar2
is
cursor cktmodulenamecursor is
select cktdestModuleType
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktdestModuleType is not null;
finalcktdestModuleType varchar2(10000);
slotmoduletype number;
BEGIN
 
for rec in cktmodulenamecursor loop
SELECT trunc(rec.cktdestModuleType/power(2,16)) INTO slotmoduletype FROM dual;
if cktmodulenamecursor%ROWCOUNT = 1 then
finalcktdestModuleType:= slotmoduletype;
else
finalcktdestModuleType := finalcktdestModuleType||','||slotmoduletype;
end if;
end loop;
return finalcktdestModuleType;
END;
/

3.3.9 collapsedmodulename

CREATE or replace function collapsedmodulename (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktmodulenamecursor is
select CKTCTPMODULETYPE
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type = 2
and CKTCTPMODULETYPE is not null;
finalcktdestModuleType varchar2(10000);
slotmoduletype number;
 
BEGIN
 
for rec in cktmodulenamecursor loop
SELECT trunc(rec.CKTCTPMODULETYPE/power(2,16)) INTO slotmoduletype FROM dual;
if cktmodulenamecursor%ROWCOUNT = 1 then
finalcktdestModuleType:= slotmoduletype;
else
finalcktdestModuleType := finalcktdestModuleType||','||slotmoduletype;
end if;
end loop;
 
return finalcktdestModuleType;
 
END collapsedmodulename;
/

3.3.10 collapsedobjectindex

CREATE or replace function collapsedobjectindex(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktifindexcursor is
select CktDestObjectType
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktDestObjectType is not null;
finalifindex varchar2(10000);
BEGIN
 
for rec in cktifindexcursor loop
if cktifindexcursor%ROWCOUNT = 1 then
finalifindex:= rec.CktDestObjectType;
else
finalifindex := finalifindex||','||rec.CktDestObjectType;
end if;
end loop;
return finalifindex;
END;
/

3.3.11 collapsedobjectindex

CREATE or replace function collapsedobjectindex(CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktifindexcursor is
select CktCtpObjectType
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CTP_TYPE = 2;
finalifindex varchar2(10000);
BEGIN
 
for rec in cktifindexcursor loop
if cktifindexcursor%ROWCOUNT = 1 then
finalifindex:= rec.CktCtpObjectType;
else
finalifindex := finalifindex||','||rec.CktCtpObjectType;
end if;
end loop;
 
return finalifindex;
 
END;
/

3.3.12 collapsedphy

CREATE or replace function collapsedphy(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktphysicalloc is
select cktDestPhysicalloc
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktDestPhysicalloc is not null;
finalphy varchar2(10000);
BEGIN
 
for rec in cktphysicalloc loop
if cktphysicalloc%ROWCOUNT = 1 then
finalphy:= rec.cktDestPhysicalloc;
else
finalphy := finalphy||','||rec.cktDestPhysicalloc;
end if;
end loop;
return finalphy;
END;
/

3.3.13 collapsedphy

CREATE or replace function collapsedphy (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor cktphysicalloc_cursor is
select CKTCTPPHYSICALLOC
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type = 2
and CKTCTPPHYSICALLOC is not null;
finalphy varchar2(10000);
BEGIN
 
for rec in cktphysicalloc_cursor loop
if cktphysicalloc_cursor%ROWCOUNT = 1 then
finalphy:= rec.CKTCTPPHYSICALLOC;
else
finalphy := finalphy||','||rec.CKTCTPPHYSICALLOC;
end if;
end loop;
 
return finalphy;
 
END collapsedphy;
/

3.3.14 collapsedport

CREATE or replace function collapsedport(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return varchar2
is
cursor cktdestcursor is
select cktdestportname
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktdestportname is not null;
finaldest varchar2(10000);
BEGIN
 
for rec in cktdestcursor loop
if cktdestcursor%ROWCOUNT = 1 then
finaldest:= rec.cktdestportname;
else
finaldest := finaldest||','||rec.cktdestportname;
end if;
end loop;
return finaldest;
END;
/

3.3.15 collapsedportmodulename

CREATE or replace function collapsedportmodulename(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return
varchar2
is
cursor cktmodulenamecursor is
select cktdestModuleType
from circuit_dest_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and cktdestModuleType is not null;
finalcktdestModuleType varchar2(10000);
portmoduletype number;
BEGIN
 
for rec in cktmodulenamecursor loop
SELECT trunc(mod(rec.cktdestModuleType,power(2,16))) INTO portmoduletype FROM dual;
if cktmodulenamecursor%ROWCOUNT = 1 then
finalcktdestModuleType:= portmoduletype;
else
finalcktdestModuleType := finalcktdestModuleType||','||portmoduletype;
end if;
end loop;
return finalcktdestModuleType;
END;
/

3.3.16 collapsedportmodulename

CREATE OR REPLACE function collapsedportmodulename(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar) return
varchar2
is
cursor cktmodulenamecursor is
select cktctpModuleType
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type = 2
and cktctpModuleType is not null;
finalcktdestModuleType varchar2(10000);
portmoduletype number;
BEGIN
 
for rec in cktmodulenamecursor loop
SELECT trunc(mod(rec.cktctpModuleType,power(2,16))) INTO portmoduletype FROM dual;
if cktmodulenamecursor%ROWCOUNT = 1 then
finalcktdestModuleType:= portmoduletype;
else
finalcktdestModuleType := finalcktdestModuleType||','||portmoduletype;
end if;
end loop;
return finalcktdestModuleType;
END;
/

3.3.17 convertaxxifindex

CREATE OR REPLACE function convertaxxifindex(ifindex in number)
RETURN number
IS
newifindex NUMBER ;
firstByte INTEGER ;
secondByte INTEGER ;
thirdByte INTEGER ;
forthByte INTEGER ;
fifthByte INTEGER ;
result number(20);
BEGIN
 
if ifindex = 0 then
return 0;
else
newifindex := ifindex - 1;
end if;
 
fifthByte := mod(newifindex, 4);
newifindex := floor(newifindex / 4);
forthByte := mod(newifindex, 8);
newifindex := floor(newifindex / 8);
thirdByte := mod(newifindex, 4);
newifindex := floor(newifindex / 4);
--secondByte := mod(newifindex, 4) + 1;
secondByte := mod(newifindex, 3) + 1;
newifindex := floor(newifindex / 3);
--firstByte := mod(newifindex, 4) + 1;
firstByte := mod(newifindex, 3) + 1;
 
result := 0;
result := result + (firstByte * POWER(2,56));
result := result + (secondByte * POWER(2,48));
result := result + (thirdByte * POWER(2,40));
result := result + (forthByte * POWER(2,32));
result := result + (fifthByte * POWER(2,24));
 
RETURN result;
END convertaxxifindex;
/

3.3.18 convertLinkModuleType

CREATE OR REPLACE function convertLinkModuleType (aModuleType number, aModelType number)
RETURN number
AS
finalModuleType number(8);
BEGIN
if (aModelType in (3,14,5,24,18,30)) then
if(aModuleType < 0 or aModuleType > 2000) then
finalModuleType := aModuleType;
else
finalModuleType := aModuleType * power(2, 16);
end if;
else
finalModuleType := aModuleType;
end if;
 
return finalModuleType;
END;
/

3.3.19 ctmduration

create or replace function ctmduration(p_ctmduration in number)
return varchar2
IS
CTMDuration_time varchar2(50);
dddd varchar2(4);
hh number:=0;
mm number:=0;
ss number:=0;
hh_c varchar2(4);
mm_c varchar2(4);
ss_c varchar2(4);
 
BEGIN
IF (p_ctmduration = 0 ) THEN
CTMDuration_time:='';
ELSE
SELECT trunc(p_ctmduration) INTO dddd FROM dual;
SELECT trunc((p_ctmduration-dddd)*24) INTO hh FROM dual;
IF ( hh <10 and hh>0 ) THEN
hh_c:='0'||hh||'h:';
ELSIF (hh > 10) THEN
hh_c:=hh||'h:';
END IF;
SELECT trunc((p_ctmduration-dddd)*24*60)-hh*60 INTO mm FROM dual;
IF (mm <10 and mm>0) THEN
mm_c:='0'||mm||'m:';
ELSIF (mm>10) THEN
mm_c:=mm||'m:';
END IF;
SELECT trunc((p_ctmduration-dddd)*24*60*60)-hh*60*60-mm*60 INTO ss from dual;
IF (ss < 10 and ss>0 ) THEN
ss_c:='0'||ss||'s';
ELSIF (ss>10) THEN
ss_c:=ss||'s';
END IF;
 
IF (dddd=0 or dddd is null) THEN
CTMDuration_time:=rtrim(hh_c||mm_c||ss_c,':');
ELSE
CTMDuration_time:=rtrim(dddd||'d:'||hh_c||mm_c||ss_c,':');
END IF;
END IF;
return CTMDuration_time;
END ctmduration;
/

3.3.20 displayif

displayif 関数は、neifindex の変換に使用されます。

CREATE or REPLACE function displayif (neifindex in number)
RETURN varchar2
IS
iftype number;
if1 number;
if2 number;
o_if2 number;
if3 number;
o_if3 number;
ifstring varchar2(10);
o_interface varchar2(20);
i_neifindex number;
 
BEGIN
IF neifindex < 0 THEN
i_neifindex := neifindex+power(2,32);
ELSE
i_neifindex:=neifindex;
END IF;
SELECT trunc(i_neifindex/power(2,24)) INTO iftype FROM dual;
 
SELECT decode(iftype,1,'System',
2,'Equipment',
3,'BITS',
4,'Sync-NE',
5,'Env Alarm',
6,'SDCC',
7,'Env CTL',
8,'Chassis',
9,'Ext-Sync',
10,'AIP',
11,'FAN',
12,'Port',
13,'CRS',
14,'RSMS',
15,'STM1E',
20,'EC-N',
21,'OC-N',
30,'DS-0',
31,'DS-1',
32,'DS-2',
33,'DS-3',
35,'STSRNG',
36,'AICI_AEP',
37,'AICI_AIE',
38,'UDC_A',
39,'UDC_B',
40,'VT-1',
45,'STS',
47,'UCP_CKT',
48,'UCP_IPCC',
49,'UCP_NBR',
55,'Ethernet',
56,'Ethernet-G',
57,'Ethernet-Brg',
58,'Ethernet-gige',
60,'PPP',
63,'E4',
65,'ATM',
66,'AAL5',
70,'VIDEO',
75,'XTC',
76,'CAP',
77,'CHANNEL',
80,'STM',
81,'E1',
82,'E3',
83,'DS3I',
90,'GENERIC',
100,'PIRELLI',
101,'STS',
102,'STS1',
103,'STS3',
104,'STS6',
105,'STS9',
106,'STS12',
107,'STS24',
108,'STS48',
109,'STS192',
110,'STS254',
111,'VC4-2C',
112,'VC4-3C',
113,'VC4-4C',
114,'VC4-8C',
115,'VC4-16C',
116,'VC4-64C',
117,'VC11',
118,'VC4',
119,'VC3',
120,'VC12',
201,'SER-DS1',
202,'E1-Port',
203,'SER-E1',
204,'STM1',
205,'VC4',
206,'VC3',
207,'VC2',
208,'VC12'
)
INTO ifstring FROM dual;
 
IF (ifstring='Equipment') THEN
o_interface:= 'Equipment';
ELSE
SELECT trunc(mod(i_neifindex,power(2,8))) INTO if3 FROM dual;
SELECT decode(if3,0,'',if3) INTO o_if3 FROM dual;
SELECT mod(trunc(i_neifindex/power(2,8)),power(2,8)) INTO if2 FROM dual;
SELECT decode(if2,0,'',if2) INTO o_if2 FROM dual;
SELECT mod(trunc(i_neifindex/power(2,16)),power(2,8)) INTO if1 FROM dual;
 
IF ( if1 != 0 ) THEN
o_interface := ifstring||' #'||if1||' '||o_if2||' '||o_if3;
ELSE
o_interface := ifstring||' '||o_if2||' '||o_if3;
END IF;
END IF;
 
RETURN o_interface;
 
END displayif;

3.3.21 displayIp

Create or replace function displayIp (NEIpaddr in number)
return varchar2
IS
 
first_sec number;
second_sec number;
third_sec number;
fourth_sec number;
ipaddr varchar2(100);
neipaddr_o number;
BEGIN
--dbms_output.put_line(neipaddr);
 
if neipaddr < 0 then
neipaddr_o:=neipaddr+power(2,32);
else
neipaddr_o:=neipaddr;
end if;
 
SELECT trunc(mod(NEIPaddr_o/power(2,24), power(2,8))) into first_sec from dual;
SELECT trunc(mod(NEIPaddr_o/power(2,16), power(2,8))) INTO second_sec from dual;
SELECT trunc(mod(NEIPaddr_o/power(2,8),power(2,8))) INTO third_sec from dual;
SELECT trunc(mod(NEIPaddr_o,power(2,8))) INTO fourth_sec from dual;
 
ipaddr:=first_sec||'.'||second_sec||'.'||third_sec||'.'||fourth_sec;
 
RETURN ipaddr;
END displayip;
 
/

3.3.22 displayphyloc

displayphyloc 関数を使って、物理位置を指定します。

Create or replace function displayphyloc (physicalloc in number)
return varchar2
IS
o_physicalloc varchar2(40);
nemodelindex number;
port number;
slot number;
pim number;
ppm number;
rack number;
shelf number;
nemodel varchar2(30);
BEGIN
SELECT trunc(mod(physicalloc,power(2,10))) INTO port from dual;
SELECT mod(trunc(physicalloc/power(2,10)),power(2,6)) INTO ppm from dual;
SELECT mod(trunc(physicalloc/power(2,16)),power(2,8)) INTO pim from dual;
SELECT mod(trunc(physicalloc/power(2,24)),power(2,8)) INTO slot from dual;
SELECT mod(trunc(physicalloc/power(2,32)),power(2,8)) INTO shelf from dual;
SELECT mod(trunc(physicalloc/power(2,40)),power(2,8)) INTO rack from dual;
 
o_physicalloc :='Rack:'||rack||',Shelf:'||shelf||',Slot:'||slot||',Port:'||port;
 
RETURN o_physicalloc;
END displayphyloc;

3.3.23 eqptinfoport

CREATE or replace function eqptinfoport(NEDBACCESSID_param number,
PHYSICALLOC_param number,
IFINDEX_param number,
MODULEINDEX_param number
) return varchar2
is
portnameselected varchar2(4000);
calc_OBJECTINDEX number;
PHYSICALLOC_temp number;
NEMODELTYPE_param number;
NEMODELINDEX_param number;
calc_Ifindex number(20);
SlotModuleType number;
PortModuleType number;
BEGIN
begin
select
NEMODELTYPE,
NEMODELINDEX
into
NEMODELTYPE_param,
NEMODELINDEX_param
from ne_info_table
where nedbaccessid = NEDBACCESSID_param;
exception
when no_data_found then
null;
end;
SlotModuleType:= getSlotModuleType(MODULEINDEX_param);
SELECT trunc(mod(MODULEINDEX_param,power(2,16))) INTO PortModuleType FROM dual;
 
--create_file('/oraclesw9i','testf.log', 'NEMODELTYPE_param :'||NEMODELTYPE_param||'NEMODELINDEX_param :'||NEMODELINDEX_param);
 
if (SlotModuleType = 157 or SlotModuleType = 146) then
calc_OBJECTINDEX:= mapobjectIndex(neModelType_param , nemodelIndex_param , getport(PHYSICALLOC_param) ,0, PortModuleType);
else
calc_OBJECTINDEX:= mapobjectIndex(neModelType_param , nemodelIndex_param , getport(PHYSICALLOC_param) ,0, SlotModuleType);
end if;
 
-- append_file('/oraclesw9i', 'testf.log', 'calc_OBJECTINDEX: '||calc_OBJECTINDEX);
-- append_file('/oraclesw9i','testf.log', 'PHYSICALLOC_param:'||PHYSICALLOC_param);
-- append_file('/oraclesw9i','testf.log','calc_Ifindex: '||calc_Ifindex);
 
PHYSICALLOC_temp := PHYSICALLOC_param;
if ( SlotModuleType = 47 ) then
PHYSICALLOC_temp := getPort_xtc(PHYSICALLOC_param, SlotModuleType);
end if;
 
begin
select col200 into portnameselected
from eqpt_info_table
where NEDBACCESSID = NEDBACCESSID_param
and PHYSICALLOC = PHYSICALLOC_temp
and IFINDEX = 0
and MODULETYPE = SlotModuleType
and OBJECTINDEX = calc_OBJECTINDEX;
exception
when no_data_found then
null;
end;
-- dbms_output.put_line( 'col200 :'||portnameselected);
return portnameselected;
END;
/

3.3.24 get_enet_value

CREATE OR REPLACE function get_enet_value(
param1 IN number,
param2 IN number,
param3 IN number default -4,
param4 IN number default -4,
param5 IN number default -4,
param6 IN number default -4)
return number
IS
r_value number ;
val1 number ;
val2 number ;
val3 number ;
val4 number ;
val5 number ;
val6 number ;
BEGIN
 
IF(param3 =-4 and param4 =-4 and param5 =-4 and param6 =-4) THEN
IF(param1 < 0 and param2 < 0) THEN
IF ( (param1=param2)) THEN
r_value:=param1;
ELSIF (param1 = -3 or param2 = -3)THEN
r_value:= -3;
ELSIF ( param1 = -2 or param2 = -2 ) THEN
r_value:= -2;
ELSIF ( param1 = -1 or param2 = -1 ) THEN
r_value:= -1;
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 =-4) and (param5 =-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0) THEN
IF ( (param1=param2) and (param2=param3) ) THEN
r_value:=param1;
ELSIF (param1 = -3 or param2 = -3 or param3 = -3)THEN
r_value:= -3;
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 ) THEN
r_value:= -2;
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 ) THEN
r_value:= -1;
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 =-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4))) THEN
r_value:=param1;
ELSIF (param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3)THEN
r_value:= -3;
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 ) THEN
r_value:=-2;
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 ) THEN
r_value:=-1;
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 >-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0 and param5 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4) and (param4=param5))) THEN
r_value:=param1;
ELSIF (param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3 or param5 =-3)THEN
r_value:= -3;
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 or param5 = -2) THEN
r_value:=-2;
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 or param5 = -1) THEN
r_value:=-1;
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 >-4) and (param6 >-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0 and param5 < 0 and param6 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4) and (param4=param5) and (param5=param6))) THEN
r_value:=param1;
ELSIF(param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3 or param5 =-3 or param6=-3) THEN
r_value:= -3;
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 or param5 = -2 or param6 = -2) THEN
r_value:=-2;
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 or param5 = -1 or param6 = -1) THEN
r_value:=-1;
END IF;
return r_value;
END IF;
END IF;
 
 
IF ( param1 <0 ) THEN
val1:= 0;
ELSE
val1:= param1;
END IF;
IF ( param2 <0 ) THEN
val2:= 0;
ELSE
val2:= param2;
END IF;
IF ( param3 <0 ) THEN
val3:= 0;
ELSE
val3:= param3;
END IF;
IF ( param4 <0 ) THEN
val4:= 0;
ELSE
val4:= param4;
END IF;
IF ( param5 <0 ) THEN
val5:= 0;
ELSE
val5:= param5;
END IF;
IF ( param6 <0 ) THEN
val6:= 0;
ELSE
val6:= param6;
END IF;
 
r_value:=val1+val2+val3+val4+val5+val6;
 
 
return r_value;
END get_enet_value;
/

3.3.25 get_enet_value2

CREATE OR REPLACE function get_enet_value2(
param1 IN number,
param2 IN number,
param3 IN number default -4,
param4 IN number default -4,
param5 IN number default -4,
param6 IN number default -4)
return varchar
IS
r_value varchar(25) ;
val1 number ;
val2 number ;
val3 number ;
val4 number ;
val5 number ;
val6 number ;
BEGIN
 
IF(param3 =-4 and param4 =-4 and param5 =-4 and param6 =-4) THEN
IF(param1 < 0 and param2 < 0) THEN
IF ( (param1=param2)) THEN
r_value:=to_char(param1);
ELSIF (param1 = -3 or param2 = -3)THEN
r_value:=to_char(-3);
ELSIF ( param1 = -2 or param2 = -2 ) THEN
r_value:=to_char(-2);
ELSIF ( param1 = -1 or param2 = -1 ) THEN
r_value:=to_char(-1);
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 =-4) and (param5 =-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0) THEN
IF ( (param1=param2) and (param2=param3) ) THEN
r_value:=to_char(param1);
ELSIF (param1 = -3 or param2 = -3 or param3 = -3)THEN
r_value:=to_char(-3);
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 ) THEN
r_value:=to_char(-2);
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 ) THEN
r_value:=to_char(-1);
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 =-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4))) THEN
r_value:=to_char(param1);
ELSIF (param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3)THEN
r_value:=to_char(-3);
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 ) THEN
r_value:=to_char(-2);
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 ) THEN
r_value:=to_char(-1);
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 >-4) and (param6 =-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0 and param5 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4) and (param4=param5))) THEN
r_value:=to_char(param1);
ELSIF (param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3 or param5 =-3)THEN
r_value:=to_char(-3);
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 or param5 = -2) THEN
r_value:=to_char(-2);
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 or param5 = -1) THEN
r_value:=to_char(-1);
END IF;
return r_value;
END IF;
ELSIF((param3 > -4) and (param4 > -4) and (param5 >-4) and (param6 >-4)) THEN
IF(param1 < 0 and param2 < 0 and param3 < 0 and param4 < 0 and param5 < 0 and param6 < 0) THEN
IF ( ((param1=param2) and (param2=param3) and (param3=param4) and (param4=param5) and (param5=param6))) THEN
r_value:=to_char(param1);
ELSIF(param1 = -3 or param2 = -3 or param3 = -3 or param4 = -3 or param5 =-3 or param6=-3) THEN
r_value:=to_char(-3);
ELSIF ( param1 = -2 or param2 = -2 or param3 = -2 or param4 = -2 or param5 = -2 or param6 = -2) THEN
r_value:=to_char(-2);
ELSIF ( param1 = -1 or param2 = -1 or param3 = -1 or param4 = -1 or param5 = -1 or param6 = -1) THEN
r_value:=to_char(-1);
END IF;
return r_value;
END IF;
END IF;
 
 
 
IF ( param1 <0 ) THEN
val1:= 0;
ELSE
val1:= param1;
END IF;
IF ( param2 <0 ) THEN
val2:= 0;
ELSE
val2:= param2;
END IF;
IF ( param3 <0 ) THEN
val3:= 0;
ELSE
val3:= param3;
END IF;
IF ( param4 <0 ) THEN
val4:= 0;
ELSE
val4:= param4;
END IF;
IF ( param5 <0 ) THEN
val5:= 0;
ELSE
val5:= param5;
END IF;
IF ( param6 <0 ) THEN
val6:= 0;
ELSE
val6:= param6;
END IF;
 
r_value:=to_char(val1+val2+val3+val4+val5+val6);
 
 
return r_value;
END get_enet_value2;
/

3.3.26 getBGFromBGObj

Create or replace function getBGFromBGObj(neifindex in number)
return number
IS
if1 number;
i_neifindex number;
 
BEGIN
 
IF neifindex < 0 THEN
i_neifindex := neifindex+power(2,32);
ELSE
i_neifindex:=neifindex;
END IF;
 
SELECT mod(trunc(i_neifindex/power(2,16)),power(2,8)) INTO if1 FROM dual;
 
RETURN if1;
END getBGFromBGObj;
/

3.3.27 getBGFromQoSObj

Create or replace function getBGFromQoSObj (neifindex in number)
return number
IS
if2 number;
o_if2 number;
i_neifindex number;
BEGIN
 
IF neifindex < 0 THEN
i_neifindex := neifindex+power(2,32);
ELSE
i_neifindex:=neifindex;
END IF;
 
SELECT mod(trunc(i_neifindex/power(2,8)),power(2,8)) INTO if2 FROM dual;
SELECT decode(if2,0,'',if2) INTO o_if2 FROM dual;
 
RETURN o_if2;
END getBGFromQoSObj;
/

3.3.28 getCktDestNodeId

CREATE or replace function getCktDestNodeId (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
cursor cktnodeidcursor is
select CktCtpNodeId
from circuit_ctp_tbl
where CktNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 2;
 
finalinodeids varchar2(10000);
BEGIN
 
for rec in cktnodeidcursor loop
if cktnodeidcursor%ROWCOUNT = 1 then
finalinodeids:= rec.CktCtpNodeId;
else
finalinodeids := finalinodeids||','||rec.CktCtpNodeId;
end if;
end loop;
 
return finalinodeids;
 
END getCktDestNodeId;
/

3.3.29 getCktSecSrcIfIndex

CREATE or replace function getCktSecSrcIfIndex (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_CktSecSrcIfIndex number;
BEGIN
select CktCtpIfIndex into o_CktSecSrcIfIndex
from circuit_ctp_tbl
where CktCtpNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 1;
 
return o_CktSecSrcIfIndex;
 
END getCktSecSrcIfIndex;
/

3.3.30 getCktSecSrcPhysicalLoc

CREATE or replace function getCktSecSrcPhysicalLoc (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_CktSecSrcPhysicalLoc number;
BEGIN
select CktCtpPhysicalLoc into o_CktSecSrcPhysicalLoc
from circuit_ctp_tbl
where CktCtpNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 1;
 
return o_CktSecSrcPhysicalLoc;
 
END getCktSecSrcPhysicalLoc;
/

3.3.31 getCktSecSrcPortName

CREATE or replace function getCktSecSrcPortName (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
o_CktSecSrcPortName varchar2(64);
BEGIN
select CKTCTPPORTNAME into o_CktSecSrcPortName
from circuit_ctp_tbl
where CktNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 1;
 
return o_CktSecSrcPortName;
 
END getCktSecSrcPortName;
/

3.3.32 getCktSrcIfIndex

CREATE or replace function getCktSrcIfIndex (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_CktSrcIfIndex number;
BEGIN
select CktCtpIfIndex into o_CktSrcIfIndex
from circuit_ctp_tbl
where CktCtpNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 0;
 
return o_CktSrcIfIndex;
 
END getCktSrcIfIndex;
/

3.3.33 getCktSrcPhysicalLoc

CREATE or replace function getCktSrcPhysicalLoc (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_CktSrcPhysicalLoc number;
BEGIN
select CktCtpPhysicalLoc into o_CktSrcPhysicalLoc
from circuit_ctp_tbl
where CktCtpNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 0;
 
return o_CktSrcPhysicalLoc;
 
END getCktSrcPhysicalLoc;
/

3.3.34 getCktSrcPortName

CREATE or replace function getCktSrcPortName (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
o_CktSrcPortName varchar2(64);
BEGIN
select CKTCTPPORTNAME into o_CktSrcPortName
from circuit_ctp_tbl
where CktNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 0;
 
return o_CktSrcPortName;
 
END getCktSrcPortName;
/

3.3.35 getcollapsedPortname

CREATE or replace function getcollapsedPortname(CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor eqptcollpasedport is
select CktNodeId,
CktCtpPhysicalLoc,
CktCtpIfIndex,
CktCtpModuleType
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktNodeId is not null
and CktCtpPhysicalLoc is not null
and CktCtpIfIndex is not null
and CktCtpModuleType is not null;
 
finaleqptinfoport varchar2(10000);
DestNedbaccessid varchar2(1000);
BEGIN
 
for rec in eqptcollpasedport loop
SELECT nedbaccessid INTO DestNedbaccessid
FROM ne_info_table
WHERE nenodeid= rec.CktNodeId and rec.CktNodeId != 0;
 
if eqptcollpasedport%ROWCOUNT = 1 then
finaleqptinfoport:= '@'||eqptinfoport(DestNedbaccessid,rec.CktCtpPhysicalLoc,rec.CktCtpIfIndex,rec.CktCtpModuleType);
else
finaleqptinfoport := finaleqptinfoport||','||'@'||eqptinfoport(DestNedbaccessid,rec.CktCtpPhysicalLoc,rec.CktCtpIfIndex,rec.CktCtpModuleType);
end if;
end loop;
 
return finaleqptinfoport;
 
END;
/

3.3.36 getEqptInfoPhysicalLoc

Create or replace function getEqptInfoPhysicalLoc(physicalLoc in number,moduleIndex in number)
return number
IS
eqptphysicalLoc number;
eqptport number;
slot number;
port number;
pim number;
ppm number;
slotmoduletype number;
portmoduletype number;
BEGIN
slot:= getSlot(physicalLoc);
port:= getPortWithPimPpm(physicalLoc);
pim:= getPIM(physicalLoc);
ppm:= getPPM(physicalLoc);
slotmoduletype:=getSlotModuleType(moduleIndex);
SELECT trunc(mod(moduleIndex,power(2,16))) INTO portmoduletype FROM dual;
IF (pim = 0 AND slotmoduletype = 157 AND portmoduletype != 34 AND ppm = 0) THEN
port:= port + 21;
eqptphysicalLoc:= getPhysicalLoc(slot,port);
ELSE
eqptphysicalLoc:= physicalLoc;
END IF;
RETURN eqptphysicalLoc;
END getEqptInfoPhysicalLoc;
/

3.3.37 GetInterfaceId

create or replace function GetInterfaceId
(p_nedbaccessid IN number,
p_moduleorIfIndex IN number,
p_objectType IN number,
p_type IN varchar2)
return varchar2
IS
o_interfaceId varchar2(64);
o_modeltype number:=0;
BEGIN
IF (p_moduleOrIfindex = 0 ) THEN
IF (p_objectType = 0 ) THEN
select activevalue into o_interfaceId from ctm_config_table
where sectionname='transportManager' and propertyname='ems-sys-id';
ELSE
SELECT nemodeltype INTO o_modeltype
FROM ne_info_table
WHERE nedbaccessid=p_nedbaccessid;
IF (o_modeltype = 34) THEN
o_interfaceId:='N/A';
ELSE
o_interfaceId:='0';
END IF;
END IF;
END IF;
 
IF (p_moduleOrIfindex = -1) THEN
o_interfaceId:='N/A';
END IF;
 
IF ((p_moduleOrIfindex != 0 ) and (p_moduleOrIfindex != -1)) THEN
IF (p_nedbaccessid =0 ) THEN
IF (p_type like 'Maximum Login Attempts Exceeded%') THEN
BEGIN
SELECT username INTO o_interfaceId
FROM user_table
WHERE userid=p_moduleorIfIndex;
exception
when no_data_found then
o_interfaceId:= displayIp(p_moduleOrIfindex);
END;
ELSIF (p_type like 'Server Monitor Threshold Crossed%') THEN
select displayname into o_interfaceId
FROM SERVER_PARAMETER_TABLE
WHERE ParameterIndex=p_moduleorIfIndex;
ELSE
SELECT nesysid INTO o_interfaceId
FROM ne_info_table
WHERE nedbaccessid=p_moduleorIfIndex AND nemodeltype!=34;
END IF;
ELSIF (p_type like 'PoS Port shutdown.L2 Topology in wrapped state%') THEN
select TOPOLOGY_NAME into o_interfaceId
FROM L2TOPOLOGY_TABLE
WHERE TOPOUNIQUEID = p_moduleorIfIndex;
ELSE
SELECT nemodeltype INTO o_modeltype
FROM ne_info_table
WHERE nedbaccessid=p_nedbaccessid;
 
IF (o_modeltype = 34) THEN
o_interfaceId:='N/A';
ELSE
o_interfaceId:=p_moduleorIfIndex;
END IF;
END IF;
END IF;
RETURN o_interfaceId;
END GetInterfaceId;
/

3.3.38 getLowBits

CREATE OR REPLACE function getLowBits (aNum number, numOfBits integer)
RETURN integer
AS
result number;
modVal number;
BEGIN
modVal := power (2, numOfBits);
result := mod (aNum, modVal);
return result;
END;
/

3.3.39 getMgx88xxMgmtState

create or replace function getMgx88xxMgmtState(p_isConnected in number)
return number
IS
i_mstate number;
BEGIN
IF ( p_isConnected = 1 ) THEN
i_mstate := 1;
ELSE
i_mstate := 2;
END IF;
 
RETURN i_mstate;
 
END getMgx88xxMgmtState;
/

3.3.40 getMgx88xxSyncMode

create or replace function getMgx88xxSyncMode(p_discoveryState in number)
return number
IS
i_mode number;
BEGIN
IF ( p_discoveryState = 1 ) THEN
i_mode := 5;
ELSE IF ( p_discoveryState = 2 ) THEN
i_mode := 1;
ELSE IF ( p_discoveryState = 3 ) THEN
i_mode := 2;
ELSE IF ( p_discoveryState = 4 ) THEN
i_mode := 3;
ELSE
i_mode := 1;
END IF;
END IF;
END IF;
END IF;
 
RETURN i_mode;
 
END getMgx88xxSyncMode;
/

3.3.41 getModelTypeFromPhysicalloc

CREATE OR REPLACE function getModelTypeFromPhysicalloc (aPHYSICALLOC number)
RETURN number
AS
aModelType number(20);
BEGIN
aModelType := removeLowBits(aPHYSICALLOC, 56);
return aModelType;
END;
/

3.3.42 getModuleName

create or replace function getModuleName(p_nedbaccessid in number, p_moduletype in number, p_eventType in number)
return varchar2
IS
o_modulename varchar2(64);
i_modeltype number;
BEGIN
IF ( p_nedbaccessid = 0 or ( p_eventType >= 4 AND p_moduletype = 9999) ) THEN
o_modulename := 'N/A';
ELSE
SELECT nemodeltype INTO i_modeltype
FROM ne_info_table
WHERE nedbaccessid=p_nedbaccessid;
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_moduletype
AND modeltype=i_modeltype;
END IF;
 
RETURN o_modulename;
 
Exception
WHEN NO_DATA_FOUND
THEN null;
END getModuleName;
/

3.3.43 getModuleName_pm

create or replace function getModuleName_pm(p_nenodeid in number, p_moduletype in number)
return varchar2
IS
o_modulename varchar2(64);
i_modeltype number;
 
BEGIN
IF (p_nenodeid=0 OR p_moduletype=0) THEN
o_modulename:='SYSTEM';
ELSE
 
SELECT nemodeltype INTO i_modeltype
FROM ne_info_table
WHERE nenodeid=p_nenodeid;
 
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_moduletype
AND modeltype=i_modeltype;
END IF;
 
RETURN o_modulename;
END getModuleName_pm;
/

3.3.44 getModuleName1

create or replace function getModuleName1(p_nenodeid in number, p_moduletype in number)
return varchar2
IS
o_modulename varchar2(64);
i_modeltype number;
p_slotmoduletype number;
 
BEGIN
SELECT trunc(p_moduletype/power(2,16)) INTO p_slotmoduletype FROM dual;
IF (p_nenodeid=0 OR p_slotmoduletype=0) THEN
o_modulename:='SYSTEM';
ELSE
 
SELECT nemodeltype INTO i_modeltype
FROM ne_info_table
WHERE nenodeid=p_nenodeid;
 
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_slotmoduletype
AND modeltype=i_modeltype;
END IF;
 
RETURN o_modulename;
END getModuleName1;
/

3.3.45 getModuleName2

create or replace function getModuleName2 (p_moduletype number, p_modeltype number)
return varchar2
IS
o_modulename varchar2(64);
p_slotmoduletype number;
BEGIN
SELECT trunc(p_moduletype/power(2,16)) INTO p_slotmoduletype FROM dual;
IF (p_slotmoduletype=0) THEN
o_modulename:='SYSTEM';
ELSE
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_slotmoduletype
AND modeltype=p_modeltype;
END IF;
 
RETURN o_modulename;
 
END getModuleName2;
/

3.3.46 getNEDBACCESSID

create or replace function getNEDBACCESSID(NodeId_param number)
return number
is
nedbaccessout number;
begin
begin
select
nedbaccessid
into nedbaccessout
from
ne_info_table
where
NENODEID = NodeId_param
and NENODEID !=0;
exception
when no_data_found then
null;
end;
return nedbaccessout;
 
end;
/

3.3.47 getObjectTypeFromIfIndex

CREATE OR REPLACE function getObjectTypeFromIfIndex (aIfindex number)
RETURN number
AS
aObjectType number(10);
BEGIN
if(sign(aIfindex) = -1) then
aObjectType := removeLowBits(aIfindex+power(2,32), 24);
else
aObjectType := removeLowBits(aIfindex, 24);
end if;
 
return aObjectType;
END;
/

3.3.48 getObjectTypeFromIfIndex2

CREATE OR REPLACE function getObjectTypeFromIfIndex2 ( amodelType number,aIfindex number)
RETURN number
AS
aObjectType number(10);
BEGIN
if(sign(aIfindex) = -1) then
aObjectType := removeLowBits(aIfindex+power(2,32), 24);
else
aObjectType := removeLowBits(aIfindex, 24);
end if;
if (amodelType in (3, 14, 5, 29, 18, 30)) THEN
select decode(aobjectType, 19, 5130,
83, 5073,
aobjectType+5000) into aobjectType from dual;
end if;
 
return aObjectType;
END;
/

3.3.49 getPhysicalLoc

Create or replace function getPhysicalLoc(slot in number,port in number)
return number
IS
physicalLoc number;
physlot number;
BEGIN
 
physlot:= slot * power(2,16);
physicalLoc:= physlot + port;
 
RETURN physicalLoc;
END getPhysicalLoc;
/

3.3.50 getPIM

Create or replace function getPIM (physicalloc in number)
return number
IS
pim number;
BEGIN
 
SELECT trunc(mod(trunc(physicalloc/power(2,16)),power(2,8))) INTO pim from dual;
 
RETURN pim;
END getPIM;
/

3.3.51 GetPMParameterValue

CREATE OR REPLACE function GetPMParameterValue
(p_paramvalue IN number,
l_paramvalue IN number
)
return number
IS
o_paramvalue number;
BEGIN
IF (p_paramvalue = -1 AND l_paramvalue <> -1) THEN
o_paramvalue:= l_paramvalue;
ELSIF (l_paramvalue = -1 AND p_paramvalue <> -1) THEN
o_paramvalue:= p_paramvalue;
ELSE
o_paramvalue:= p_paramvalue;
END IF;
RETURN o_paramvalue;
END GetPMParameterValue;
/

3.3.52 getPolicyMapType

Create or replace function getPolicyMapType(neifindex in number)
return number
IS
if1 number;
i_neifindex number;
 
BEGIN
 
IF neifindex < 0 THEN
i_neifindex := neifindex+power(2,32);
ELSE
i_neifindex:=neifindex;
END IF;
 
SELECT mod(trunc(i_neifindex/power(2,16)),power(2,8)) INTO if1 FROM dual;
 
RETURN if1;
END getPolicyMapType;
/

3.3.53 getPort

Create or replace function getPort (physicalloc in number)
return number
IS
port number;
ppm number;
BEGIN
SELECT trunc(mod(physicalloc,power(2,10))) INTO port from dual;
 
RETURN port;
END getPort;
 
/

3.3.54 getPort_xtc

Create or replace function getPort_xtc (physicalloc in number, moduletype_param in number )
return number
IS
port number;
final_physicalloc number;
two_bytes number := power(2,16);
BEGIN
 
SELECT trunc(mod(physicalloc,two_bytes)) INTO port from dual;
if ( moduletype_param = 47 ) then
-- append_file('/oraclesw9i', 'testfjune9.log', 'Port No. Passed is : '|| port);
if ( port <= 28 ) then
port := 1;
else
port := mod (port, 28);
if (port = 0) then
port := 28;
end if;
end if;
 
-- append_file('/oraclesw9i', 'testfjune9.log', 'Returning port no. : '|| port);
end if;
 
final_physicalloc := trunc(physicalloc/two_bytes) * two_bytes;
final_physicalloc := final_physicalloc + port;
 
RETURN final_physicalloc;
END getPort_xtc;
/

3.3.55 getPortModuleName

create or replace function getPortModuleName(p_nenodeid in number, p_moduletype in number)
return varchar2
IS
o_modulename varchar2(64);
i_modeltype number;
p_portmoduletype number;
BEGIN
SELECT trunc(mod(p_moduletype,power(2,16))) INTO p_portmoduletype FROM dual;
IF (p_nenodeid=0 OR p_portmoduletype=0) THEN
o_modulename:='SYSTEM';
ELSE
SELECT nemodeltype INTO i_modeltype
FROM ne_info_table
WHERE nenodeid=p_nenodeid;
 
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_portmoduletype
AND modeltype=i_modeltype;
END IF;
RETURN o_modulename;
END getPortModuleName;
/

3.3.56 getPortModuleName2

create or replace function getPortModuleName2(p_moduleindex number, p_modeltype number)
return varchar2
IS
o_modulename varchar2(64);
p_portmoduletype number;
BEGIN
SELECT mod(p_moduleindex, power(2,16)) INTO p_portmoduletype FROM dual;
IF (p_portmoduletype=0 ) THEN
o_modulename:= getModuleName2(p_moduleindex, p_modeltype);
ELSE
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_portmoduletype
AND modeltype=p_modeltype;
END IF;
 
RETURN o_modulename;
END getPortModuleName2;
/

3.3.57 GetPortName

CREATE or REPLACE function GetPortName
(p_nedbaccessid IN number,
p_physicalloc IN number,
p_ifindex IN number,
p_moduletype IN number)
RETURN varchar2
IS
iftype number;
i_ifindex number;
o_portname varchar2(256);
model_type number;
module_type number;
physical_loc number;
ppm number;
slot number;
port number;
BEGIN
 
IF p_ifindex < 0 THEN
i_ifindex := p_ifindex+power(2,32);
ELSE
i_ifindex:=p_ifindex;
END IF;
module_type := p_moduletype;
ppm := GetPpm(p_physicalloc);
 
SELECT round(i_ifindex/power(2,24)) INTO iftype FROM dual;
SELECT nemodeltype INTO model_type FROM ne_info_table WHERE nedbaccessid = p_nedbaccessid;
BEGIN
 
IF ( iftype = 31 and p_moduletype=47 ) THEN
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex=204
AND moduletype=p_moduletype;
ELSIF (iftype = 33 and p_moduletype = 47 ) THEN
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex=208
AND moduletype=p_moduletype;
ELSIF (p_moduletype = 34 ) THEN
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex=204
AND moduletype=47;
ELSIF (p_moduletype = 32 ) THEN
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex=208
AND moduletype=47;
ELSIF (p_moduletype = 102 or p_moduletype = 103 or p_moduletype = 163 or p_moduletype = 164 or p_moduletype = 187 ) THEN
IF (p_ifindex = 1) THEN
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex in (136,257);
ELSE
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND objectindex in (134,255);
END IF;
ELSIF (ppm>0) THEN
slot := GetSlot(p_physicalloc);
port := GetPort(p_physicalloc);
SELECT equipmenttype INTO module_type
FROM ons15454_ne_inventory_table
WHERE nedbaccessid = p_nedbaccessid and physicalloc = getPhysicalLoc(slot,65535);
IF(model_type = 3 or model_type = 14) THEN
physical_loc := getPhysicalLoc(slot,port);
ELSE
physical_loc := p_physicalloc;
END IF;
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=physical_loc
AND moduleType=module_type
AND objectindex in (106,109,114,115,121,122,123,125,134,136,141,142,143,147,169,184,185,193,196,198,204,206,208,209,216,252,254,255,257,267,271,281);
ELSE
SELECT col200 INTO o_portname
FROM eqpt_info_table
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND moduleType=p_moduletype
AND objectindex in (106,109,114,115,121,122,123,125,134,136,141,142,143,147,169,184,185,193,196,198,204,206,208,209,216,252,254,255,257,267,271,281);
END IF;
EXCEPTION
WHEN TOO_MANY_ROWS
THEN null;
END;
 
RETURN o_portname;
 
END GetPortName;
/

3.3.58 getPortWithPimPpm

Create or replace function getPortWithPimPpm (physicalloc in number)
return number
IS
port number;
BEGIN
 
SELECT trunc(mod(physicalloc,power(2,13))) INTO port from dual;
 
RETURN port;
END getPortWithPimPpm;
/

3.3.59 getPPM

Create or replace function getPPM (physicalloc in number)
return number
IS
ppm number;
BEGIN
 
SELECT trunc(mod(trunc(physicalloc/power(2,10)),power(2,6))) INTO ppm from dual;
 
RETURN ppm;
END getPPM;
 
/

3.3.60 getSlot

Create or replace function getSlot (physicalloc in number)
return number
IS
slot number;
BEGIN
 
SELECT mod(trunc(physicalloc/power(2,24)),power(2,8)) INTO slot from dual;
 
RETURN slot;
END getSlot;
 
/

3.3.61 getSlotModuleName

create or replace function getSlotModuleName(p_nenodeid in number, p_moduletype in number)
return varchar2
IS
o_modulename varchar2(64);
i_modeltype number;
p_slotmoduletype number;
BEGIN
SELECT trunc(p_moduletype/power(2,16)) INTO p_slotmoduletype FROM dual;
IF (p_nenodeid=0 OR p_slotmoduletype=0) THEN
o_modulename:='SYSTEM';
ELSE
SELECT nemodeltype INTO i_modeltype
FROM ne_info_table
WHERE nenodeid=p_nenodeid;
 
SELECT ModuleName INTO o_modulename
FROM module_type_table
WHERE moduletype=p_slotmoduletype
AND modeltype=i_modeltype;
END IF;
RETURN o_modulename;
END getSlotModuleName;
/

3.3.62 getSlotModuleType

create or replace function getSlotModuleType(p_moduletype in number)
return varchar2
IS
p_slotmoduletype number;
BEGIN
SELECT trunc(p_moduletype/power(2,16)) INTO p_slotmoduletype FROM dual;
RETURN p_slotmoduletype;
END getSlotModuleType;
/

3.3.63 getspantblCktSpanDestNodeId

CREATE or replace function getspantblCktSpanDestNodeId (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor ctpspandestnodeidcursor is
select CKTCTPNODEID
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and ctp_type=4;
 
ctpspandestnodeid_list varchar2(10000);
BEGIN
 
for rec in ctpspandestnodeidcursor loop
if ctpspandestnodeidcursor%ROWCOUNT = 1 then
ctpspandestnodeid_list:= rec.CKTCTPNODEID;
else
ctpspandestnodeid_list := ctpspandestnodeid_list||','||rec.CKTCTPNODEID;
end if;
end loop;
 
return ctpspandestnodeid_list;
 
END getspantblCktSpanDestNodeId;
/

3.3.64 getspantblCktSpanSrcNodeId

CREATE or replace function getspantblCktSpanSrcNodeId (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return varchar2
IS
cursor ctpspansrcnodeidcursor is
select CKTCTPNODEID
from circuit_ctp_tbl
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID=CKTUNIQUEIDIN
and ctp_type=3;
 
finalspansrcnodeid_list varchar2(10000);
BEGIN
 
for rec in ctpspansrcnodeidcursor loop
if ctpspansrcnodeidcursor%ROWCOUNT = 1 then
finalspansrcnodeid_list:= rec.CKTCTPNODEID;
else
finalspansrcnodeid_list := finalspansrcnodeid_list||','||rec.CKTCTPNODEID;
end if;
end loop;
 
return finalspansrcnodeid_list;
 
END getspantblCktSpanSrcNodeId;
/

3.3.65 getSubIf

Create or replace function getSubIf(neifindex in number)
return number
IS
i_neifindex number;
subifindex number;
BEGIN
 
IF neifindex < 0 THEN
i_neifindex := neifindex+power(2,32);
ELSE
i_neifindex:=neifindex;
END IF;
 
SELECT mod(trunc(i_neifindex/power(2,16)),power(2,16)) INTO subifindex FROM dual;
 
RETURN subifindex;
END getSubIf;
/

3.3.66 getValidCktSecSrcNodeId

CREATE or replace function getValidCktSecSrcNodeId (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_CktSedSrcNodeId number;
BEGIN
select CktCtpNodeId into o_CktSedSrcNodeId
from circuit_ctp_tbl
where CktNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 1;
 
return o_CktSedSrcNodeId;
 
END getValidCktSecSrcNodeId;
/

3.3.67 getValidCktSrcnodeid

CREATE or replace function getValidCktSrcnodeid (CKTNODEIDIN number,CKTUNIQUEIDIN number)
return number
IS
o_ValidCktSrcnodeid number;
BEGIN
select CktCtpNodeId into o_ValidCktSrcnodeid
from circuit_ctp_tbl
where CktNodeId = CKTNODEIDIN
and CktUniqueId = CKTUNIQUEIDIN
and ctp_type = 0;
 
return o_ValidCktSrcnodeid;
 
END getValidCktSrcnodeid;
/

3.3.68 getValidModelType

create or replace function getValidModelType (CktNodeIdIN number, CktUniqueIdIN number, ctp_typeIN number)
return number
IS
o_ValidModelType number;
BEGIN
select CKTCTPMODELTYPE into o_ValidModelType
from circuit_ctp_tbl
where CktNodeId = CktNodeIdIN
and CktUniqueId = CktUniqueIdIN
and ctp_type = ctp_typeIN;
 
return o_ValidModelType;
 
END getValidModelType;
/

3.3.69 getValidModuleType

create or replace function getValidModuleType (CktNodeIdIN number, CktUniqueIdIN number, ctp_typeIN number)
return number
IS
o_ValidModuleType number;
BEGIN
select CKTCTPMODULETYPE into o_ValidModuleType
from circuit_ctp_tbl
where CktNodeId = CktNodeIdIN
and CktUniqueId = CktUniqueIdIN
and ctp_type = ctp_typeIN;
 
return o_ValidModuleType;
 
END getValidModuleType;
/

3.3.70 getValidObjectType

create or replace function getValidObjectType (CktNodeIdIN number, CktUniqueIdIN number, ctp_typeIN number)
return number
IS
o_ValidObjectType number;
BEGIN
select CKTCTPOBJECTTYPE into o_ValidObjectType
from circuit_ctp_tbl
where CktNodeId = CktNodeIdIN
and CktUniqueId = CktUniqueIdIN
and ctp_type = ctp_typeIN;
 
return o_ValidObjectType;
 
END getValidObjectType;
/

3.3.71 mapobjectIndex

CREATE or replace function mapobjectIndex(neModelType number,
nemodelIndex number,
portnumber number,
iftype number,
moduletype number) return number
is
ObjIndex number;
BEGIN
 
if (neModelType = 18 or neModelType = 30) and
(moduleType = 28 or moduleType = 29 or moduleType = 30) then
return 147;
end if;
if moduleType = 9 or moduleType = 106 or moduleType = 10 or
moduleType = 11 or moduleType = 12 or moduleType = 13 or
moduleType = 28 or moduleType = 29 or moduleType = 30 or
moduleType =60 or moduleType = 85 or moduleType = 86 or moduleType = 87 then
return 109;
elsif neModelType = 3 and moduleType = 4 then
return 114;
elsif neModelType = 3 and moduleType = 5 then
return 114;
elsif neModelType = 5 and moduleType = 4 then
return 204;
elsif neModelType = 14 and moduleType = 4 then
return 114;
elsif neModelType = 14 and moduleType = 5 then
return 114;
elsif moduleType = 6 or moduleType = 7 or moduleType = 57 or moduleType = 58 then
return 121;
elsif moduleType = 102 or moduleType = 103 then
return 136;
elsif moduleType = 8 then
if nemodelIndex >= 61 then
return 270;
else
return 123;
end if;
elsif moduletype = 47 and portnumber <= 28 then
return 204;
elsif moduletype = 47 and portnumber >28 then
return 208;
elsif moduletype = 7 or moduletype = 8 then
return 114;
elsif moduletype = 14 then
return 106;
elsif moduletype = 15 then
return 206;
elsif moduletype = 31 then
return 109;
elsif moduletype = 32 then
return 208;
elsif moduletype = 34 then
return 204;
elsif moduletype = 62 then
return 209;
elsif moduletype = 118 and portnumber = 1 then
return 141;
elsif moduletype = 118 and portnumber = 2 then
return 142;
elsif moduletype = 119 and portnumber >= 1 and portnumber <= 4 then
return 141;
elsif moduletype = 119 and portnumber =5 then
return 142;
elsif moduletype = 120 and portnumber = 1 then
return 141;
elsif moduletype = 120 and portnumber = 2 then
return 142;
elsif moduletype = 121 and portnumber = 1 then
return 141;
elsif (moduletype = 121 and (portnumber = 2 or portnumber = 3)) then
return 142;
elsif moduletype = 127 and portnumber = 1 then
return 198;
elsif (moduletype = 127 and (portnumber = 2 or portnumber = 3)) then
return 193;
elsif moduletype = 128 and portnumber = 1 then
return 198;
elsif moduletype = 128 and portnumber >= 2 and portnumber <= 7 then
return 193;
elsif moduletype = 129 and portnumber = 2 then
return 196;
elsif (moduletype = 129 and (portnumber = 1 or portnumber = 3 or portnumber = 4)) then
return 193;
elsif moduletype = 130 and portnumber = 6 then
return 196;
elsif moduletype = 130 and portnumber >= 1 and portnumber <= 5 then
return 193;
elsif moduletype = 131 and portnumber >= 1 and portnumber <= 32 then
return 194;
elsif moduletype = 131 and portnumber = 33 then
return 193;
elsif moduletype = 132 and portnumber >= 1 and portnumber <= 32 then
return 194;
elsif moduletype = 132 and portnumber = 33 then
return 193;
elsif moduletype = 133 and portnumber >= 1 and portnumber <= 8 then
return 194;
elsif moduletype = 133 and portnumber = 9 or portnumber = 10 then
return 195;
elsif (moduletype = 134 and (portnumber = 1 or portnumber = 2)) then
return 194;
elsif moduletype = 134 and portnumber >= 3 and portnumber <= 6 then
return 193;
elsif moduletype = 135 and portnumber >= 1 and portnumber <= 4 then
return 194;
elsif moduletype = 135 and portnumber >= 5 and portnumber <= 8 then
return 193;
elsif moduletype = 136 and portnumber >= 1 and portnumber <= 8 then
return 194;
elsif moduletype = 136 and portnumber >= 9 and portnumber <= 12 then
return 193;
elsif moduletype = 137 and portnumber >= 1 and portnumber <= 2 then
return 195;
elsif moduletype = 137 and portnumber >= 3 and portnumber <= 6 then
return 193;
elsif moduletype = 138 and portnumber >= 1 and portnumber <= 8 then
return 195;
elsif moduletype = 138 and portnumber >= 9 and portnumber <= 12 then
return 193;
elsif moduletype = 143 then
return 216;
elsif moduletype = 145 then
return 262;
elsif moduletype = 163 or moduletype = 164 or moduletype = 187 then
return 257;
elsif moduletype = 108 or moduletype = 83 or moduletype = 64 or moduletype = 65 or moduletype =66 or
moduletype = 67 then
if nemodelindex = 33 then
return 121;
else
return 114;
end if;
else
return 0;
end if;
END;
/

3.3.72 mergedInvalidityList

CREATE OR REPLACE function mergedInvalidityList(lineTableValue in integer, lineInvalidityList in varchar2, pathInvalidityList in varchar2) return varchar2 as
 
TYPE column_name IS RECORD (
table_name VARCHAR2(50),
view_name VARCHAR2(50)
);
TYPE column_names IS TABLE OF column_name index by binary_integer;
column_list column_names;
 
tblName USER_TAB_COLUMNS.TABLE_NAME%TYPE;
dbColumnNo USER_TAB_COLUMNS.COLUMN_ID%TYPE;
occurence integer;
value USER_TAB_COLUMNS.COLUMN_ID%TYPE;
startPos integer;
offSet integer;
mergedInvalidityList varchar2(100);
 
 
begin
if(lineInvalidityList is null ) then
return pathInvalidityList;
end if;
 
if(length(trim(lineInvalidityList)) =0 ) then
return pathInvalidityList;
end if;
 
if(lineTableValue = -1) then
return pathInvalidityList;
end if;
tblName := 'ONS15454_SONET_LINE_PM_TABLE';
mergedInvalidityList := pathInvalidityList;
 
column_list(1).table_name := 'PPJCPDET';
column_list(1).view_name := 'PPJC_PDET';
column_list(2).table_nam