Table Of Contents
Packages, Procedures, Functions, and Triggers
3.1 CTM Packages
3.1.1 CTMAlarm
3.1.2 MSMCircuit
3.1.3 prune_package
3.2 CTM Stored Procedures
3.2.1 add_circuit_ctps_to_met
3.2.2 add_log_partition
3.2.3 add_pm_partition
3.2.4 alter_user_permission
3.2.5 append_file
3.2.6 BulkNEAddition
3.2.7 clear_allunack_alarms
3.2.8 create_file
3.2.9 execute_dml_statement
3.2.10 execute_statement
3.2.11 Login_Disable
3.2.12 PortName
3.2.13 prune_audittrail
3.2.14 prune_ne
3.2.15 prune_pm
3.2.16 reset_seq
3.2.17 update_portnames
3.3 CTM Functions
3.3.1 collapseddestnodename
3.3.2 collapseddestnodename
3.3.3 collapsedeqptportname
3.3.4 collapsedifindex
3.3.5 collapsedifindex
3.3.6 collapsedmodeltype
3.3.7 collapsedmodeltype
3.3.8 collapsedmodulename
3.3.9 collapsedmodulename
3.3.10 collapsedobjectindex
3.3.11 collapsedobjectindex
3.3.12 collapsedphy
3.3.13 collapsedphy
3.3.14 collapsedport
3.3.15 collapsedportmodulename
3.3.16 collapsedportmodulename
3.3.17 convertaxxifindex
3.3.18 convertLinkModuleType
3.3.19 ctmduration
3.3.20 displayif
3.3.21 displayIp
3.3.22 displayphyloc
3.3.23 eqptinfoport
3.3.24 get_enet_value
3.3.25 get_enet_value2
3.3.26 getBGFromBGObj
3.3.27 getBGFromQoSObj
3.3.28 getCktDestNodeId
3.3.29 getCktSecSrcIfIndex
3.3.30 getCktSecSrcPhysicalLoc
3.3.31 getCktSecSrcPortName
3.3.32 getCktSrcIfIndex
3.3.33 getCktSrcPhysicalLoc
3.3.34 getCktSrcPortName
3.3.35 getcollapsedPortname
3.3.36 getEqptInfoPhysicalLoc
3.3.37 GetInterfaceId
3.3.38 getLowBits
3.3.39 getMgx88xxMgmtState
3.3.40 getMgx88xxSyncMode
3.3.41 getModelTypeFromPhysicalloc
3.3.42 getModuleName
3.3.43 getModuleName_pm
3.3.44 getModuleName1
3.3.45 getModuleName2
3.3.46 getNEDBACCESSID
3.3.47 getObjectTypeFromIfIndex
3.3.48 getObjectTypeFromIfIndex2
3.3.49 getPhysicalLoc
3.3.50 getPIM
3.3.51 GetPMParameterValue
3.3.52 getPolicyMapType
3.3.53 getPort
3.3.54 getPort_xtc
3.3.55 getPortModuleName
3.3.56 getPortModuleName2
3.3.57 GetPortName
3.3.58 getPortWithPimPpm
3.3.59 getPPM
3.3.60 getSlot
3.3.61 getSlotModuleName
3.3.62 getSlotModuleType
3.3.63 getspantblCktSpanDestNodeId
3.3.64 getspantblCktSpanSrcNodeId
3.3.65 getSubIf
3.3.66 getValidCktSecSrcNodeId
3.3.67 getValidCktSrcnodeid
3.3.68 getValidModelType
3.3.69 getValidModuleType
3.3.70 getValidObjectType
3.3.71 mapobjectIndex
3.3.72 mergedInvalidityList
3.3.73 removefirstbyteif
3.3.74 removeLowBits
3.3.75 TYPE AlarmInfoListType
3.3.76 TYPE AlarmInfoType
3.3.77 TYPE link_id_tabtype
3.4 CTM Triggers
3.4.1 aat_before_trigger
3.4.2 aat_trigger
3.4.3 act_trigger
3.4.4 aft_del_l2ckttable_trigger
3.4.5 aft_del_l2interface_trigger
3.4.6 aft_ins_l2interface_trigger
3.4.7 aft_insdel_bridgegroup_trigger
3.4.8 circuit_tbl_alias_trigger
3.4.9 ckt_tbl_alias_trigger
3.4.10 deleted_user_trigger
3.4.11 link_tbl_alias_trigger
3.4.12 nit_trigger
3.4.13 ut_trigger
Packages, Procedures, Functions, and Triggers
This chapter describes the stored packages, procedures, functions, and triggers defined in CTM tables. It contains the following sections:
•
CTM Packages
•
CTM Stored Procedures
•
CTM Functions
•
CTM Triggers
3.1 CTM Packages
This section describes the packages that are defined in CTM tables. The packages are listed in alphabetical order.
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_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
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_linkid IN link_id_tabtype,
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_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN varchar2
(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_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN varchar2
(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_linkid IN link_id_tabtype,
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_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
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
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_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN varchar2)
--INVALID_ALARM_STATUS EXCEPTION;
--PRAGMA EXCEPTION_INIT (INVALID_ALARM_STATUS, -20002);
total_num_linkid number:=0;
IF (p_alarmstatus = 0) THEN
INSERT INTO active_alarm_table (
ACTIVEALARMADDITIONALINFO,
p_activealarmadditionalinfo,
activealarmindex_seq.nextval,
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
UPDATE active_alarm_table
clearalarmtimestamp=to_date(''),
nealarmcleartimestamp=to_date(''),
ActiveAlarmSeverity=p_ActiveAlarmSeverity,
ActiveAlarmServEff=p_ActiveAlarmServEff,
ActiveAlarmAdditionalInfo=p_ActiveAlarmAdditionalInfo,
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;
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
SET NumWarningAlarms=NumWarningAlarms+1
WHERE linkid=p_linkid(table_row);
IF (p_activealarmseverity = 5) Then
SET NumMinorAlarms=NumMinorAlarms+1
WHERE linkid = p_linkid(table_row);
IF (p_activealarmseverity = 6) THEN
SET NumMajorAlarms=NumMajorAlarms+1
WHERE linkid = p_linkid(table_row);
IF (p_activealarmseverity = 7) THEN
SET NumCriticalAlarms=NumCriticalAlarms+1
WHERE linkid= p_linkid(table_row);
raise INVALID_ALARM_STATUS;
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_linkid IN link_id_tabtype,
p_StrObjInstance IN varchar2)
rows_processed number :=0;
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);
IF (p_alarmstatus = 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
-- 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
------ 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
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
SET NumWarningAlarms=NumWarningAlarms-1
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
IF (p_activealarmseverity = 5) Then
SET NumMinorAlarms=NumMinorAlarms-1
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 6) THEN
SET NumMajorAlarms=NumMajorAlarms-1
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 7) THEN
SET NumCriticalAlarms=NumCriticalAlarms-1
WHERE linkid= p_linkid(table_row)
AND NumCriticalAlarms > 0;
raise INVALID_ALARM_STATUS;
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_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN varchar2)
rows_processed number :=0;
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);
IF (p_alarmstatus = 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
-- 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
------ 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);
IF (rows_processed=0) THEN
dbms_output.put_line('Alarm_not_found');
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
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
SET NumWarningAlarms=NumWarningAlarms-1
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
IF (p_activealarmseverity = 5) Then
SET NumMinorAlarms=NumMinorAlarms-1
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 6) THEN
SET NumMajorAlarms=NumMajorAlarms-1
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 7) THEN
SET NumCriticalAlarms=NumCriticalAlarms-1
WHERE linkid= p_linkid(table_row)
AND NumCriticalAlarms > 0;
raise INVALID_ALARM_STATUS;
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 (
ACTIVEALARMADDITIONALINFO,
p_activealarmadditionalinfo,
activealarmindex_seq.nextval,
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_ActiveAlarmFlag IN number,
p_ActiveAlarmComment IN varchar2 default null,
p_NEAlarmTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN varchar2
--dbms_output.put_line('alarm_handle: calling alarm_handle_impl: nedbaccessid=' ||
p_nedbaccessid || ', ActiveAlarmComment=' || p_ActiveAlarmComment || ', alarmstatus=' ||
p_alarmstatus);
p_ActiveAlarmAdditionalInfo,
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_linkid IN link_id_tabtype,
p_StrObjInstance IN varchar2
--dbms_output.put_line('clear_alarms: calling clear_alarms_impl: nedbaccessid=' ||
p_nedbaccessid || ', alarmstatus=' || p_alarmstatus);
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_ActiveAlarmFlag IN number,
p_ClearAlarmTimeStamp IN date,
p_NEAlarmTimeStamp IN date,
p_NEAlarmClearTimeStamp IN date,
p_linkid IN link_id_tabtype,
p_externalcondition IN varchar2,
p_StrObjInstance IN VARCHAR2
--dbms_output.put_line('add_clear_alarms: calling add_clear_alarms_impl:
nedbaccessid=' || p_nedbaccessid || ', alarmstatus=' || p_alarmstatus);
p_ActiveAlarmAdditionalInfo,
Procedure bulk_alarm_handle
p_AlarmInfoList IN AlarmInfoListType
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
--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);
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
Procedure bulk_clear_alarms
p_AlarmInfoList IN AlarmInfoListType
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
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);
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
Procedure bulk_add_clear_alarms
p_AlarmInfoList IN AlarmInfoListType
For I IN p_AlarmInfoList.FIRST .. p_AlarmInfoList.LAST
--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);
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
3.1.2 MSMCircuit
create TYPE circuit_bs_tbl_struct as OBJECT (
CKTDESCRIPTION VARCHAR2 (256),
CUSTOMERID VARCHAR2 (256),
SERVICEID VARCHAR2 (256),
CKTPROTECTIONTYPE NUMBER,
CKTADDITIONALINFO VARCHAR2(64),
CKTCOMMENT VARCHAR2 (2014),
CKTALIASNAME VARCHAR2 (64)
create TYPE circuit_bs_tbl_struct_list as table of circuit_bs_tbl_struct;
create TYPE circuit_identity_struct as OBJECT (
create TYPE circuit_identity_struct_list as table of circuit_identity_struct;
create TYPE circuit_ctp_tbl_struct as OBJECT (
CTPPORTNAME VARCHAR2 (64),
CTPADDITIONALINFO VARCHAR2 (64)
create TYPE circuit_ctp_tbl_struct_list as table of circuit_ctp_tbl_struct;
create TYPE circuit_span_bs_tbl_struct as OBJECT (
SRC_CTPMODULETYPE NUMBER,
SRC_CTPOBJECTINDEX NUMBER,
SRC_CTPPHYSICALLOC NUMBER,
DST_CTPMODULETYPE NUMBER,
DST_CTPOBJECTINDEX NUMBER,
DST_CTPPHYSICALLOC 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
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
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
circuit_id_list IN circuit_identity_struct_list,
Procedure delete_circuits_on_nodeList
circuit_id_list IN circuit_identity_struct_list
create or Replace package body MSMCircuit is
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
create_circuit_failed EXCEPTION;
i_CKTSPANSRCCTPACCESSID NUMBER;
i_CKTSPANDSTCTPACCESSID NUMBER;
p_CKTCTPNeDBAccessId NUMBER;
i := circuit_bs_tbl_data.FIRST;
p_npid := circuit_bs_tbl_data(i).NPID;
-- 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;
-- when no_data_found then
-- raise create_circuit_failed;
--Remove all old data from the tables if any
delete from circuit_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
delete from circuit_ctp_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
insert into circuit_bs_tbl
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,
circuit_bs_tbl_data(i).CKTALIASNAME
For I IN circuit_ctp_tbl_data.FIRST .. circuit_ctp_tbl_data.LAST
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_ctp_tbl_data(i).CTPNODEID;
raise create_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
if (circuit_span_bs_tbl_data.count = 0) then
goto skip_circuit_span_bs_tbl;
For I IN circuit_span_bs_tbl_data.FIRST .. circuit_span_bs_tbl_data.LAST
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_span_bs_tbl_data(i).SRC_CTPNODEID;
raise create_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANSRCCTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_span_bs_tbl_data(i).DST_CTPNODEID;
raise create_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANDSTCTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
SELECT CKTSPANBSID_SEQ.nextval INTO i_CKTSPANBSID FROM dual;
insert into circuit_span_bs_tbl
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,
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,
<<skip_circuit_span_bs_tbl>>
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
update_circuit_failed EXCEPTION;
i_CKTSPANSRCCTPACCESSID NUMBER;
i_CKTSPANDSTCTPACCESSID NUMBER;
p_CKTCTPNeDBAccessId NUMBER;
i := circuit_bs_tbl_data.FIRST;
p_npid := circuit_bs_tbl_data(i).NPID;
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.
raise update_circuit_failed;
--For circuit_ctp_tbl and circuit_span_bs_tbl, do delete and insert, not update
delete from circuit_ctp_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_bs_tbl_data(i).CKTNODEID
and CKTUNIQUEID = circuit_bs_tbl_data(i).CKTUNIQUEID;
For I IN circuit_ctp_tbl_data.FIRST .. circuit_ctp_tbl_data.LAST
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_ctp_tbl_data(i).CTPNODEID;
raise update_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
if (circuit_span_bs_tbl_data.count = 0) then
goto skip_circuit_span_bs_tbl;
For I IN circuit_span_bs_tbl_data.FIRST .. circuit_span_bs_tbl_data.LAST
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_span_bs_tbl_data(i).SRC_CTPNODEID;
raise update_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANSRCCTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
circuit_span_bs_tbl_data(i).CKTSPANSRCPORTNAME,
select NEDBACCESSID into p_CKTCTPNeDBAccessId
where NENODEID = circuit_span_bs_tbl_data(i).DST_CTPNODEID;
raise update_circuit_failed;
SELECT CTPACCESSID_SEQ.nextval INTO i_CKTSPANDSTCTPACCESSID FROM dual;
insert into circuit_ctp_tbl
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,
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,
circuit_span_bs_tbl_data(i).CKTSPANDESTPORTNAME,
SELECT CKTSPANBSID_SEQ.nextval INTO i_CKTSPANBSID FROM dual;
insert into circuit_span_bs_tbl
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,
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,
<<skip_circuit_span_bs_tbl>>
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
rows_processed number :=0;
cursor_handle INTEGER := DBMS_SQL.OPEN_CURSOR;
statement_txt varchar2(500);
if(cktmoduletype_upd_flag = 0 and cktportname_udp_flag = 0) then
statement_txt := 'update circuit_ctp_tbl set ';
if (cktmoduletype_upd_flag = 1) then
statement_txt := statement_txt || 'CKTCTPMODULETYPE = ' || p_cktmoduletype;
if (cktportname_udp_flag = 1) then
statement_txt := statement_txt || ', CKTCTPPORTNAME = ' || ''''
||p_cktportname||'''';
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);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
circuit_id_list IN circuit_identity_struct_list,
For I IN circuit_id_list.FIRST .. circuit_id_list.LAST
delete from circuit_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
delete from CIRCUIT_VCG_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
delete from circuit_ctp_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID
and CKTUNIQUEID = circuit_id_list(i).CKTUNIQUEID;
Procedure delete_circuits_on_nodeList
circuit_id_list IN circuit_identity_struct_list
For I IN circuit_id_list.FIRST .. circuit_id_list.LAST
delete from circuit_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
delete from CIRCUIT_VCG_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID;
delete from circuit_ctp_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
delete from circuit_span_bs_tbl
where CKTNODEID = circuit_id_list(i).CKTNODEID;
delete from CIRCUIT_VLAN_TBL
where CKTNODEID = circuit_id_list(i).CKTNODEID;
3.1.3 prune_package
3.1.3.1 prune_package for Small Configurations
CREATE OR REPLACE PACKAGE Prune AS
rows_to_be_deleted NUMBER := 100000 ;
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_server_monitor( intervaldays IN number);
PROCEDURE prune_admin_job_table( intervaldays IN number);
CREATE OR REPLACE PACKAGE BODY Prune AS
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
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
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysId ;
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
FETCH IsThisAGNE INTO lv_GNEId ;
FOR rec IN GneChildren(lv_GNEId) LOOP
dbms_output.put_line('NE : '||rec.nesysid);
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
WHERE gne.gnesysid = iv_NESysid ;
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
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 ;
FETCH IsThisAGNE INTO lv_GNEId ;
OPEN GneChildren (lv_GNEId ) ;
FETCH GneChildren INTO lv_NESysId ;
IF GNEChildren%NOTFOUND THEN
PROCEDURE prune_auditlog( intervaldays IN number ) AS
rows_processed number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
SELECT activevalue INTO ORACLE_SID
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;
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);
rows_processed:=rows_processed+counter;
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);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.err','Error
in pruning audit log '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_errorlog(intervaldays IN number) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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;
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);
rows_processed:=rows_processed+counter;
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);
rows_processed:=rows_processed+counter;
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'));
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_errorlog.err','Error in
pruning error log '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_fm(intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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);
FOR i IN (select rowid from alarm_event_table
where AlarmEventTimeStamp < prunedate and rownum <=
rows_to_be_deleted) LOOP
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);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from alarm_event_table at '|| sysdate);
FOR i IN (select rowid from ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and rownum <= rows_to_be_deleted) LOOP
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);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.err','Error in
pruning fm log '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_server_monitor( intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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);
FOR i IN (select rowid from SERVER_MONITOR_TABLE
where CollectionTime < prunedate and rownum <= rows_to_be_deleted)
LOOP
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM SERVER_MONITOR_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM SERVER_MONITOR_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.err','Error in
prune server monitor table '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_admin_job_table( intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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);
FOR i IN (select rowid from ADMIN_JOB_TABLE
where ScheduledTIme < prunedate and rownum <= rows_to_be_deleted)
LOOP
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error in
prune admin job table '||SQLERRM||', '||SQLCODE);
3.1.3.2 prune_package for Medium, Large, and High-End Configurations
CREATE OR REPLACE PACKAGE Prune AS
rows_to_be_deleted NUMBER := 100000 ;
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);
CREATE OR REPLACE PACKAGE BODY Prune AS
PROCEDURE Prune_log(p_table_name in varchar2, intervaldays in number, log_file in
varchar2)
partition_to_be_pruned varchar2(9);
statement_txt varchar2(500);
statement_txt_1 varchar2(500);
rows_processed number := 0;
rows_processed_1 number :=0;
err_file := 'prune_'||p_table_name||'.err';
SELECT activevalue INTO ORACLE_SID
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%'
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
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);
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)
--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);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',log_file,'prune
'||p_table_name||' successfully finished at '||sysdate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump',err_file,'Error in pruning
'||p_table_name||': '||SQLERRM||', '||SQLCODE);
PROCEDURE CheckGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
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
WHERE ne.gneid = iv_gneId AND
ne.nesysid <> iv_NESysId ;
lv_GNEId ne_info_table.GNEId%TYPE := NULL ;
FETCH IsThisAGNE INTO lv_GNEId ;
FOR rec IN GneChildren(lv_GNEId) LOOP
dbms_output.put_line('NE : '||rec.nesysid);
PROCEDURE PruneGNE ( iv_NESysId IN ne_info_table.NESysId%TYPE ) AS
WHERE gne.gnesysid = iv_NESysid ;
CURSOR GneChildren ( iv_GNEId ne_info_table.gneid%TYPE ) IS
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 ;
FETCH IsThisAGNE INTO lv_GNEId ;
OPEN GneChildren (lv_GNEId ) ;
FETCH GneChildren INTO lv_NESysId ;
IF GNEChildren%NOTFOUND THEN
PROCEDURE prune_auditlog( intervaldays IN number ) AS
rows_processed number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
SELECT activevalue INTO ORACLE_SID
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');
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_auditlog.err','Error
in pruning audit log '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_errorlog(intervaldays IN number) AS
SELECT activevalue INTO ORACLE_SID
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');
PROCEDURE prune_fm(intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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);
FOR i IN (select rowid from alarm_event_table
where AlarmEventTimeStamp < prunedate and rownum <=
rows_to_be_deleted) LOOP
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);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM alarm_event_table
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from alarm_event_table at '|| sysdate);
FOR i IN (select rowid from ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and rownum <= rows_to_be_deleted) LOOP
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);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_fm.err','Error in
pruning fm log '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_server_monitor( intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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');
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_servermonitor.err','Error in
prune server monitor table '||SQLERRM||', '||SQLCODE);
PROCEDURE prune_admin_job_table( intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
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) ;
FOR i IN (select rowid from ADMIN_JOB_TABLE
where ScheduledTIme < prunedate and rownum <= rows_to_be_deleted)
LOOP
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ADMIN_JOB_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error in
prune admin job table '||SQLERRM||', '||SQLCODE);
3.2 CTM Stored Procedures
This section describes the stored procedures that are defined in CTM tables. The procedures are listed in alphabetical order.
3.2.1 add_circuit_ctps_to_met
CREATE or REPLACE PROCEDURE add_circuit_ctps_to_met
p_CustomerId varchar2(256);
p_ServiceId varchar2(256);
p_PHYSICALLOC number(20);
p_NEDBAccessID number(10);
select c.CktType, c.CustomerId, c.ServiceId,
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
insert into Managed_Et_tab
WHEN DUP_VAL_ON_INDEX then
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;
select c.CKTSECSRCMODULETYPE,
c.CKTSECSRCOBJECTTYPE, n.NEDBAccessID
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;
insert into Managed_Et_tab
WHEN DUP_VAL_ON_INDEX then
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;
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
insert into Managed_Et_tab
WHEN DUP_VAL_ON_INDEX then
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;
select v.DESTNEMODULETYPE CktDestModuleType,
v.DESTPHYSICALLOC CktDestPhysicalLoc,
v.INTERFACEID CktDestIfIndex,
v.DESTOBJECTTYPE CktDestObjectType, v.DESTNEDBACCESSID NEDBAccessID
where v.NODEID = p_CktNodeId
and v.UNIQUEID = p_CktUniqueId
insert into Managed_Et_tab
WHEN DUP_VAL_ON_INDEX then
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;
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
3.2.2 add_log_partition
Note
The add_log_partition procedure applies only to medium, large, and high-end configurations.
create or replace procedure add_log_partition AS
partition_to_be_added varchar2(9);
statement_txt varchar2(500);
rows_processed number := 0;
p_tablespace_name varchar2(25);
new_partition_name varchar2(9);
SELECT activevalue INTO ORACLE_SID
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
'ERROR_LOG_TABLE', 'SERVER_MONITOR_TABLE',
'NE_AUDIT_TRAIL_TABLE', 'ONS158XX_LAC_LOG_TABLE'
Select max(to_date( substr(partition_name,2,9))),tablespace_name
INTO new_partition_date, p_tablespace_name
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
new_partition_date:= new_partition_date+1;
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);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log',rec.table_n
ame||' already has log partitions for the next 3 days');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.log','Adding
partition successfully finished at '||sysdate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_log_partition.err','Error in
adding pm partition '||SQLERRM||', '||SQLCODE);
3.2.3 add_pm_partition
Note
The add_pm_partition procedure applies only to medium, large, and high-end configurations.
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);
statement_txt varchar2(500);
rows_processed number := 0;
p_tablespace_name varchar2(25);
new_partition_name varchar2(9);
pm_service_enabled varchar2(15);
SELECT activevalue INTO ORACLE_SID
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')
Select max(to_date( substr(partition_name,2,9))),tablespace_name
INTO new_partition_date, p_tablespace_name
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
new_partition_date:= new_partition_date+1;
-- check whether pm-service is enabled, if no, no need to add partitions
Select activevalue INTO pm_service_enabled
where propertyname='pm-service'
and
upper(rtrim(sectionname,'-pm'))=substr(rec.table_name,1,instr(rec.table_name,'_',1)-1) ;
Select activevalue INTO pm_service_enabled
where propertyname='pm-service'
and
upper(rtrim(sectionname,'-pm'))=replace(substr(rec.table_name,1,instr(rec.table_name,'_',1
)-1),'01','XX');
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);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',rec.table_na
me||' already has partitions for the next 3 days');
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');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','Adding
partition successfully finished at '||sysdate);
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','add_pm_partition.err','Error in
adding pm partition '||SQLERRM||', '||SQLCODE);
3.2.4 alter_user_permission
create or replace PROCEDURE alter_user_permission
IF (AddOrRemove = 'Remove') THEN
FOR rec IN (select userid FROM user_table
where subtypeofUser=userTypeId) LOOP
DELETE FROM user_map_table
error_msg:= 'Remove failed for userid '||rec.userid;
IF (AddOrRemove = 'Add') THEN
FOR rec IN (select userid FROM user_table
where subTypeOfUser=UserTypeId) LOOP
INSERT INTO user_map_table
VALUES (rec.userid, 2, -2);
error_msg:= 'Add failed for userid '||rec.userid;
3.2.5 append_file
create or replace PROCEDURE append_file
(loc_in IN varchar2, file_in IN varchar2, line_in IN varchar2 :=null)
file_handle utl_file.file_type;
file_handle := utl_file.fopen (loc_in, file_in,'A');
utl_file.put_line(file_handle,line_in);
utl_file.fclose(file_handle);
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
dbms_output.put_line('Error in appending log file');
3.2.6 BulkNEAddition
create or replace procedure BulkNEAddition
(OperationType IN number,
GroupToBeInserted IN number,
GroupDescription IN varchar2,
GroupLocationName IN varchar2,
GneToBeInserted IN number,
GroupingOption IN number,
SubNWToBeInserted IN number,
SubNwName IN OUT varchar2,
SubnetTopology IN number,
OperationalState IN number,
NeDescription IN varchar2,
SnmpCommunityString IN varchar2,
DisplayModelName IN varchar2,
GwTL1UserName IN varchar2,
GwTL1Password IN varchar2,
pmCollectionFlag IN number,
i_subNWName varchar2(64);
BulkNeAdd_FAILED EXCEPTION;
IF (GroupToBeInserted = 1) THEN
SELECT groupId_seq.nextval INTO i_groupId from dual;
INSERT INTO group_info_table
VALUES(i_groupid, GroupName,GroupDescription,'',GroupLocationName);
IF (GneToBeInserted = 1) THEN
SELECT GNEID_SEQ.nextval INTO i_gneid from dual;
VALUES(i_gneid, 0,1, GneSysid,NextHopIpaddr,'',GroupingOption,GroupPrefix,
inUserId);
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;
i_subNwName:=i_subNwName||'-1';
INSERT INTO subnetwork_table
VALUES (i_subnetid, i_subNWName,'','',SubnetType,
SubnetTopology,-1,NWPartitionId);
SELECT NEDBACCESSID_SEQ.nextval INTO i_neid FROM dual;
INSERT INTO ne_info_table
decode(inNEAliasID, null, InNESysid, inNEAliasID),
UPDATE NE_INFO_TABLE set NEIPADDR=''
SELECT Properties INTO userProperty
WHERE usertypeid = ( select subtypeofuser from user_table where userid =
InUserId);
IF (userProperty =2) THEN
SELECT count(*) INTO assigned_group
AND (GroupOrNEID IN ( SELECT parentid FROM domain_table
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);
INSERT INTO user_map_table
VALUES(inUserId, 3, i_neid);
IF (parentGroupId = 0) THEN
IF (GroupToBeInserted = 1 ) THEN
values(DT_TREENODEID_SEQ.nextval, i_parenttype, parentGroupid, 2,
i_groupid);
VALUES (DT_TREENODEID_SEQ.nextval, 2, i_groupid, 3,i_neid);
VALUES (DT_TREENODEID_SEQ.nextval, i_parenttype, parentGroupid, 3,i_neid);
INSERT INTO Cerent_Ne_Group_Table VALUES (i_neid, GroupingOption);
--create_file('/oraclesw9i','bulkneadd.log','neid:'||neId||' newGroupId:'||newGroupId||'
subNwname:'||subNwname||' subNwId:'||subNwId||' GneId:'||GneId);
3.2.7 clear_allunack_alarms
CREATE or REPLACE procedure clear_allunack_alarms
WHERE propertyname='clear-unack-alarms'
FOR rec IN (select rowid from active_alarm_table
UPDATE active_alarm_table
IF mod(counter,1000)=0 THEN
dbms_output.put_line('Total '||counter||' cleared alarms are autoacknowledged');
WHERE propertyname='clear-unack-alarms'
3.2.8 create_file
create or replace PROCEDURE create_file
(loc_in IN varchar2, file_in IN varchar2, line_in IN varchar2 :=null)
file_handle utl_file.file_type;
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);
utl_file.put_line(file_handle, 'Nothing to write');
utl_file.fclose(file_handle);
dbms_output.put_line(SQLERRM);
dbms_output.put_line(SQLCODE);
dbms_output.put_line('Error in creating log file');
3.2.9 execute_dml_statement
CREATE or REPLACE procedure execute_dml_statement
p_statement_txt in varchar2
pragma AUTONOMOUS_TRANSACTION;
execute immediate p_statement_txt;
3.2.10 execute_statement
CREATE or REPLACE PROCEDURE execute_statement
(p_statement_txt1 varchar2,
p_statement_txt2 varchar2,
p_statement_txt3 varchar2)
cursor_handle number:=DBMS_SQL.OPEN_CURSOR;
rows_processed number:=0;
statement_txt varchar2(500);
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);
IF DBMS_SQL.IS_OPEN(cursor_handle) THEN
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
3.2.11 Login_Disable
The Login_Disable procedure disables a user's login if that user does not log in for a specified period of time.
CREATE OR REPLACE PROCEDURE Login_Disable
SELECT * FROM USER_TABLE;
for rec in usertable loop
if rec.AUTODISABLEINTERVAL <> 0 then
if rec.LASTLOGINTIME is NULL then
Baseline := rec.PASSWORDSETTIME;
Baseline := rec.LASTLOGINTIME;
difference := sysdate - Baseline;
if (difference >= rec.AUTODISABLEINTERVAL) then
update user_table set USERLOGINDISABLED = 1 where userid = rec.userid;
3.2.12 PortName
CREATE or REPLACE PROCEDURE PortName
(p_nedbaccessid IN number,
o_portname varchar2(256);
SELECT col200 INTO o_portname
WHERE nedbaccessid=p_nedbaccessid
AND physicalloc=p_physicalloc
AND moduleType=p_moduletype
AND objectindex=p_objectindex;
p_portname := o_portname;
3.2.13 prune_audittrail
CREATE OR REPLACE PROCEDURE prune_audittrail( intervaldays IN number ) AS
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_processed number :=0;
rows_to_be_deleted NUMBER := 100000 ;
SELECT activevalue INTO ORACLE_SID
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);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Prune audit
trail table before '||prunedate);
FOR i IN (select rowid from NE_Audit_Trail_Table
where TIMESTAMP < prunedate and rownum <= rows_to_be_deleted) LOOP
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM NE_Audit_Trail_Table
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM NE_Audit_Trail_Table
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
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);
FOR i IN (select rowid from ONS158XX_LAC_LOG_TABLE
where DateTime < prunedate and rownum <= rows_to_be_deleted) LOOP
rowid_tab_v(counter) := i.rowid;
IF counter = rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LAC_LOG_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FORALL rid IN 1 .. counter
DELETE FROM ONS158XX_LAC_LOG_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Deleted
'||rows_processed||' rows from ONS158XX_LAC_LOG_TABLE at '|| sysdate);
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');
create_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_audittrail.err','Error in
audit trail log '||SQLERRM||', '||SQLCODE);
3.2.14 prune_ne
create or replace procedure prune_ne
prune_process_state number :=0;
rows_deleted number:=3000;
rows_processed number:=0;
rows_deleted_total number:=0;
statement_txt varchar2(500);
CURSOR IsGne(p_nesysid IN ne_info_table.nesysid%TYPE) IS
WHERE gnesysid=p_nesysid;
r_gneid ne_info_table.gneid%TYPE;
INVALID_NESYSID EXCEPTION;
PRAGMA EXCEPTION_INIT (INVALID_NESYSID, -20003);
PRAGMA EXCEPTION_INIT (PRUNE_FAILED, -20004);
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
FETCH IsGne INTO r_gneid;
dbms_output.put_line('This is a GNE , check if it has children');
SELECT count(*) INTO counter
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);
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!');
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','Proc
ess prune '||p_nesysid||' at '||prune_date);
SELECT nedbaccessid, nenodeid,neipaddr INTO p_nedbaccessid,p_nenodeid,
p_neipaddr
FOR i IN ( SELECT a.table_name,a.column_name
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
(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
a.column_name='CKTNODEID' OR
a.column_name='CHILDID' OR
a.column_name='GROUPORNEID')
SELECT decode(i.table_name,'NE_INFO_TABLE' ,1,
0) INTO prune_state
FROM dual;
IF (prune_state = 0 ) THEN
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;
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;
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;
IF (i.column_name='CKTNODEID' ) THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where
cktnodeid = '||p_nenodeid || ' AND rownum < = '||rows_deleted;
IF (i.column_name='CHILDID') THEN
statement_txt :='DELETE FROM '||i.table_name||
' WHERE childtype=3 AND childid =
'||p_nedbaccessid|| ' AND rownum < = '||rows_deleted;
-- 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;
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);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||rows_deleted_total||' from '||i.table_name);
IF ( p_nenodeid != 0 ) THEN
FOR rec IN ( SELECT rowid,cktnodeid,cktuniqueid FROM CIRCUIT_DEST_TBL
WHERE CktDestNodeId=p_nenodeid)
DELETE FROM CIRCUIT_DEST_TBL
/* UPDATE state of the circuits associated with this destination to
incomplete */
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
IF mod(counter,300) = 0 THEN
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from
CIRCUIT_DEST_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from CIRCUIT_DEST_TBL');
/* prune CIRCUIT_SPAN_TBL based on CktSpanSrcNodeId and CktSpanDestNodeId */
FOR rec IN ( SELECT rowid,cktnodeid, cktuniqueid FROM CIRCUIT_SPAN_TBL
WHERE CktSpanSrcNodeId=p_nenodeid
OR CktSpanDestNodeId=p_nenodeid)
DELETE FROM CIRCUIT_SPAN_TBL
/* UPDATE the state of the circuits associated with the span to
incomplete */
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
IF mod(counter,300) = 0 THEN
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from
CIRCUIT_SPAN_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from CIRCUIT_SPAN_TBL');
/* prune ONS155XX_GRANULAR_CC_TBL based on GCCSrcNodeId and GCCDestNodeId */
FOR rec IN ( SELECT rowid FROM ONS155XX_GRANULAR_CC_TBL
WHERE GCCSrcNodeId=p_nedbaccessid
OR GCCDestNodeId=p_nedbaccessid)
DELETE FROM ONS155XX_GRANULAR_CC_TBL
IF mod(counter,300) = 0 THEN
--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','Dele
ted rows committed '||counter||' from ONS155XX_GRANULAR_CC_TBL');
/* prune ONS155XX_CIRCUIT_CC_TBL based on CktCCNodeId */
FOR rec IN ( SELECT rowid,cktnodeid, cktuniqueid FROM ONS155XX_CIRCUIT_CC_TBL
WHERE CktCCNodeId=p_nedbaccessid )
DELETE FROM ONS155XX_CIRCUIT_CC_TBL
/* UPDATE the state of the circuits associated with the span to
incomplete */
WHERE cktnodeid=rec.cktnodeid
AND cktuniqueid=rec.cktuniqueid
IF mod(counter,300) = 0 THEN
--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','Dele
ted rows committed '||counter||' from ONS155XX_CIRCUIT_CC_TBL');
/* prune ONS155XX_PATH_TBL based on PATHSrcNodeId and PATHDestNodeId */
FOR rec IN ( SELECT rowid FROM ONS155XX_PATH_TBL
WHERE PathSrcNodeId=p_nedbaccessid
OR PathDestNodeId=p_nedbaccessid)
DELETE FROM ONS155XX_PATH_TBL
IF mod(counter,300) = 0 THEN
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from
ONS155XX_PATH_TBL');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from ONS155XX_PATH_TBL');
/* prune data from link_table */
FOR rec IN ( SELECT rowid FROM link_table
WHERE linksrcnode=p_nedbaccessid OR
linkdstnode=p_nedbaccessid)
IF mod(counter,300) = 0 THEN
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from
link_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from link_table');
/* prune data from ne_info_table */
DELETE from ne_info_table
WHERE nedbaccessid=p_nedbaccessid;
--DBMS_output.PUT_LINE('------Deleted rows committed: '||counter||' from
ne_info_table');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from ne_info_table');
/* prune proxy_server_table */
DELETE from proxy_server_table
WHERE neipaddr=p_neipaddr;
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Dele
ted rows committed '||counter||' from proxy_server_table');
WHERE gnesysid=p_nesysid;
prune_date:=to_char(sysdate,'MM/DD/YYYY HH24:MI:SS');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','prun
e '||p_nesysid||' is finished successfully at '||prune_date);
DBMS_OUTPUT.PUT_LINE('No such network element');
append_file('/oraclesw9i/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','No
such network element');
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','Erro
r in pruning NE!'||SQLERRM||','||SQLCODE);
3.2.15 prune_pm
3.2.15.1 prune_pm Procedure for Small Configurations
Create or replace procedure prune_pm (
is24h_flag IN number default(2)
rows_processed number := 0;
statement_txt varchar2(500);
statement_txt1 varchar2(500);
statement_txt2 varchar2(500);
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
rows_to_be_deleted number := 100000;
rows_deleted_total number := 0;
sec_convertor number :=86400;
table_name varchar2(127);
SELECT activevalue INTO ORACLE_SID
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';
LOGFILE := 'prune_pm.log';
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);
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);
append_file(LOGDIR, LOGFILE,'pruning both "15min" and "1day" pm data at
'||sysdate);
-- delete entries in data tables
FOR i IN ( SELECT a.table_name,a.column_name
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
AND (a.column_name like '%TIMESTAMP%' and a.table_name like
'%_DATA')
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);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
--IF rows_processed=0 THEN
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'Deleted '||rows_deleted_total||' rows from
'||i.table_name || ' at '||sysdate );
--- 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')
WHERE object_name like '%_DATA_________' AND object_type = 'TABLE';
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
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);
DBMS_SQL.CLOSE_CURSOR (cursor_handle1);
append_file(LOGDIR,LOGFILE,'Dropped ' || table_name || ' at '||sysdate );
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);
DBMS_SQL.CLOSE_CURSOR (cursor_handle2);
append_file(LOGDIR,LOGFILE,'Deleted from scmfragdatatables - ' || table_name
|| ' at '||sysdate );
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%'
DBMS_OUTPUT.PUT_LINE('table: ' || rec.table_name);
cursor_handle := DBMS_SQL.OPEN_CURSOR;
statement_txt := 'SELECT /*+ INDEX_FFS('||rec.index_name||') */ rowid
FROM '||
rec.table_name||' where '||rec.column_name ||'<
'||''''||prunedate||''''||
' and rownum <= '||rows_to_be_deleted;
statement_txt := 'SELECT /*+ INDEX_FFS('||rec.index_name||') */ rowid
FROM '||
rec.table_name||' where '||rec.column_name ||'<
'||''''||prunedate||''''||
' and rownum <= '||rows_to_be_deleted||' and is24h =
'||is24h_flag;
DBMS_OUTPUT.PUT_LINE(statement_txt);
DBMS_SQL.PARSE(cursor_handle, statement_txt, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle);
IF DBMS_SQL.FETCH_ROWS(cursor_handle) > 0 then
DBMS_SQL.COLUMN_VALUE (cursor_handle,1, deleted_rowid);
rowid_tab_v(counter) := deleted_rowid;
IF counter = rows_to_be_deleted THEN
cursor_handle1 := DBMS_SQL.OPEN_CURSOR;
statement_txt1 := 'FORALL rid IN 1 .. counter DELETE FROM
'||rec.table_name||' WHERE rowid = rowid_tab_v(rid) ';
DBMS_OUTPUT.PUT_LINE(statement_txt1);
DBMS_SQL.PARSE(cursor_handle1, statement_txt1,
DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle1);
DBMS_SQL.CLOSE_CURSOR (cursor_handle1);
-- append_file(LOGDIR,LOGFILE,'pruned '||counter||' from
'||rec.table_name);
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
IF counter < rows_to_be_deleted THEN
cursor_handle2 := DBMS_SQL.OPEN_CURSOR;
statement_txt2 := 'FORALL rid IN 1 .. counter DELETE FROM
'||rec.table_name||' WHERE rowid = rowid_tab_v(rid) ';
DBMS_OUTPUT.PUT_LINE(statement_txt2);
DBMS_SQL.PARSE(cursor_handle2, statement_txt2, DBMS_SQL.NATIVE);
rows_processed := DBMS_SQL.EXECUTE(cursor_handle2);
DBMS_SQL.CLOSE_CURSOR (cursor_handle2);
append_file(LOGDIR,LOGFILE,'pruned '||counter||' from
'||rec.table_name);
append_file(LOGDIR,LOGFILE,'prune pm successfully finished at '||sysdate);
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');
DBMS_OUTPUT.PUT_LINE('something is wrong');
create_file(LOGDIR, 'prune_pm.err','Error in pruning pm '||SQLERRM||',
'||SQLCODE);
3.2.15.2 prune_pm Procedure for Medium, Large, and High-End Configurations
create or replace procedure Prune_pm (
is24h_flag in number default(2)
partition_to_be_pruned varchar2(9);
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;
p_partition_name varchar(30);
p_15min_subpartition_name varchar(30);
p_1day_subpartition_name varchar(30);
SELECT activevalue INTO ORACLE_SID
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';
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);
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);
append_file(LOGDIR,LOGFILE,'pruning both "15min" and "1day" pm data at
'||sysdate);
FOR i IN ( SELECT a.table_name,a.column_name
WHERE a.table_name = b.object_name
AND b.object_type='TABLE'
AND (a.column_name like '%TIMESTAMP%' and a.table_name like
'%_DATA')
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);
rows_processed:=DBMS_SQL.EXECUTE(cursor_handle);
rows_deleted_total:=rows_deleted_total+rows_processed;
--IF rows_processed=0 THEN
DBMS_SQL.CLOSE_CURSOR (cursor_handle);
append_file(LOGDIR,LOGFILE,'Deleted '||rows_deleted_total||' rows from
'||i.table_name || ' at '||sysdate );
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%'
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;
statement_txt_1 := statement_txt_1 || ' and interval=' ||is24h_flag;
--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
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);
DBMS_SQL.CLOSE_CURSOR (cursor_handle_1);
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)
--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);
elsif (is24h_flag = 0) then --15min
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_%')
--DBMS_OUTPUT.PUT_LINE(rec.table_name ||', ' || i.p15min_sp ||', '
|| i.p1day_sp);
if(i.p1day_sp is null) then
--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);
--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);
else --is24h_flag=1 for 1day
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_%')
--DBMS_OUTPUT.PUT_LINE(rec.table_name ||', ' || i.p15min_sp ||', '
|| i.p1day_sp);
if(i.p15min_sp is null) then
--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);
--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);
append_file(LOGDIR,LOGFILE,'prune pm successfully finished at '||sysdate);
create_file(LOGDIR,'prune_pm.err','Error in pruning pm log '||SQLERRM||',
'||SQLCODE);
3.2.16 reset_seq
CTM uses the reset_seq stored procedure to drop and recreate sequence numbers during migration.
CREATE or REPLACE PROCEDURE reset_seq
(p_statement_txt1 varchar2,
p_statement_txt2 varchar2,
cursor_handle number:=DBMS_SQL.OPEN_CURSOR;
rows_processed number:=0;
statement_txt varchar2(500);
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);
IF DBMS_SQL.IS_OPEN(cursor_handle) THEN
DBMS_SQL.CLOSE_CURSOR(cursor_handle);
3.2.17 update_portnames
create or replace procedure update_portnames ( NEDBPARAM
eqpt_info_table.NEDBACCESSID%TYPE,objindx eqpt_info_table.objectindex%TYPE) is
select nenodeid into nenodeid2
where nedbaccessid=nedbparam;
for rec in(select PHYSICALLOC,col200 from eqpt_info_table where NEDBACCESSID
= NEDBPARAM and objectindex=objindx) LOOP
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)
(CKTSRCPORTNAME is null and rec.col200 is not null));
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)
(CKTSECSRCPORTNAME is null and rec.col200 is not null));
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)
(CKTDESTPORTNAME is null and rec.col200 is not null));
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)
(CKTSPANSRCPORTNAME is null and rec.col200 is not null));
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)
(CKTSPANDESTPORTNAME is null and rec.col200 is not null));
3.3 CTM Functions
This section describes the functions that CTM uses. Functions read parameters and return a value. The functions are listed in alphabetical order.
3.3.1 collapseddestnodename
CREATE or replace function collapseddestnodename(CKTNODEIDIN varchar,CKTUNIQUEIDIN
varchar) return varchar2
cursor cktdestnodename is
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktDestNodeId is not null;
finaldestNode varchar2(10000);
DestNedbaccessid varchar2(1000);
for rec in cktdestnodename loop
SELECT nedbaccessid INTO DestNedbaccessid
WHERE nenodeid= rec.CktDestNodeId and rec.CktDestNodeId != 0 ;
if cktdestnodename%ROWCOUNT = 1 then
finaldestNode:= DestNedbaccessid;
finaldestNode := finaldestNode||','||DestNedbaccessid;
3.3.2 collapseddestnodename
CREATE or replace function collapseddestnodename (CKTNODEIDIN number,CKTUNIQUEIDIN number)
cursor cktdestnodename is
where CKTNODEID=CKTNODEIDIN
and CKTUNIQUEID =CKTUNIQUEIDIN
and CktCtpNodeId is not null;
finaldestNode varchar2(10000);
DestNedbaccessid varchar2(1000);
for rec in cktdestnodename loop
SELECT nedbaccessid INTO DestNedbaccessid
WHERE nenodeid= rec.CktCtpNodeId and rec.CktCtpNodeId != 0 ;
if cktdestnodename%ROWCOUNT = 1 then
finaldestNode:= DestNedbaccessid;
finaldestNode := finaldestNode||','||DestNedbaccessid;
END collapseddestnodename;
3.3.3 collapsedeqptportname
CREATE or replace function collapsedeqptportname(CKTNODEIDIN varchar,CKTUNIQUEIDIN
varchar) return varchar2
cursor eqptcollpasedport is
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);
for rec in eqptcollpasedport loop
SELECT nedbaccessid INTO DestNedbaccessid
WHERE nenodeid= rec.CktDestNodeId and rec.CktDestNodeId != 0;
if eqptcollpasedport%ROWCOUNT = 1 then
finaleqptinfoport:=
'@'||eqptinfoport(DestNedbaccessid,rec.cktDestPhysicalloc,rec.cktDestIfindex,
rec.cktdestModuleType);
finaleqptinfoport :=
finaleqptinfoport||','||'@'||eqptinfoport(DestNedbaccessid,rec.cktDestPhysicalloc,rec.cktD
estIfindex, rec.cktdestModuleType);
return finaleqptinfoport;
3.3.4 collapsedifindex
CREATE or replace function collapsedifindex(CKTNODEIDIN varchar,CKTUNIQUEIDIN varchar)
return varchar2
cursor cktobjectindexcursor is
where CKTNODEID=CKTNODEIDIN