Table Of Contents
Packages, Procedures, Functions, and Triggers
3.1 CTM Packages
3.1.1 Body DB_Info_Utility
3.1.2 Body Security_Pkg
3.1.3 Body Conversion_Utility
3.1.4 Conversion_Utility
3.1.5 CTMAlarm
3.1.6 DB_Info_Utility
3.1.7 getIPSLA_IPADDR
3.1.8 getIPSLA_SUBNETMASK
3.1.9 MSMCircuit
3.1.10 Prune_Package
3.1.11 Security_Pkg
3.1.12 Service_Availability
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 GET_NESYSID
3.2.12 Login_Disable
3.2.13 PortName
3.2.14 Prune_Audittrail
3.2.15 Prune_NE
3.2.16 Prune_PM
3.2.17 RoleOfNEs
3.2.18 Reset_Seq
3.2.19 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 CollapsedModuleName
3.3.8 CollapsedObjectIndex
3.3.9 CollapsedPhy
3.3.10 CollapsedPort
3.3.11 CollapsedPortModuleName
3.3.12 ConvertAxxIfIndex
3.3.13 ConvertLinkModuleType
3.3.14 CountCoSPh
3.3.15 CTMDuration
3.3.16 DisplayIf
3.3.17 DisplayIPAll
3.3.18 DisplayIP
3.3.19 DisplayPhyLoc
3.3.20 EqptInfoPort
3.3.21 Get_Enet_Value
3.3.22 Get_Enet_Value2
3.3.23 GetBccBwInfo
3.3.24 GetBccClassInfo
3.3.25 GetBccClassRPR80217
3.3.26 GetBccCosCommitGrp
3.3.27 GetBccCosInfo
3.3.28 GetBGFromBGObj
3.3.29 GetBGFromQoSObj
3.3.30 GetCktDestNodeId
3.3.31 GetCktSecSrcIfIndex
3.3.32 GetCktSecSrcPhysicalLoc
3.3.33 GetCktSecSrcPortName
3.3.34 GetCktSrcIfIndex
3.3.35 GetCktSrcPhysicalLoc
3.3.36 GetCktSrcPortName
3.3.37 GetCollapsedPortname
3.3.38 GetEqptInfoPhysicalLoc
3.3.39 GetIfCosGrp
3.3.40 GetInterfaceId
3.3.41 GetLowBits
3.3.42 GetMgx88xxMgmtState
3.3.43 GetMgx88xxSyncMode
3.3.44 GetMLcardAddnlInfo
3.3.45 GetModelTypeFromPhysicalLoc
3.3.46 GetModuleName
3.3.47 GetModuleName_PM
3.3.48 GetModuleName1
3.3.49 GetModuleName2
3.3.50 GetgetProtectMLcardConfigState
3.3.51 GetNEDBAccessID
3.3.52 GetNEIPAddr
3.3.53 GetObjectTypeFromIfIndex
3.3.54 GetObjectTypeFromIfIndex2
3.3.55 GetOutIPAddr
3.3.56 GetPhysicalLoc
3.3.57 GetPhysicalLocWithPIMPPM
3.3.58 GetPIM
3.3.59 GetPMParameterValue
3.3.60 GetPolicyMapType
3.3.61 GetPort
3.3.62 GetPort_XTC
3.3.63 GetPortModuleName
3.3.64 GetPortModuleName2
3.3.65 GetPortName
3.3.66 GetPortWithPIMPPM
3.3.67 GetPosPortState
3.3.68 GetPosPortStateForRPR802
3.3.69 GetPPM
3.3.70 GetProtectMLCardInfo
3.3.71 GetQoSPhLoc
3.3.72 GetShelf
3.3.73 GetSlot
3.3.74 GetSlotModuleName
3.3.75 GetSlotModuleType
3.3.76 GetSpanTblCktSpanDestNodeId
3.3.77 GetSpanTblCktSpanSrcNodeId
3.3.78 GetSubIf
3.3.79 GetValidCktSecSrcNodeId
3.3.80 GetValidCktSrcNodeId
3.3.81 GetValidModelType
3.3.82 GetValidModuleType
3.3.83 GetValidObjectType
3.3.84 Has_Next
3.3.85 IsIPv6
3.3.86 MapObjectIndex
3.3.87 MergedInvalidityList
3.3.88 NE_Belongs_to_APC_Domain
3.3.89 RemoveFirstByteIf
3.3.90 RemoveLowBits
3.3.91 Time_Diff
3.3.92 TYPE AlarmInfoListType
3.3.93 TYPE AlarmInfoType
3.3.94 TYPE Link_Id_Tabtype
3.4 CTM Triggers
3.4.1 AAT_Before_Trigger
3.4.2 AAT_New_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 NE_Desc_Trigger
3.4.13 NIT_Trigger_New
3.4.14 Security_Aft_Row_All
3.4.15 Security_Aft_Stm_All
3.4.16 Security_Bef_Stm_All
3.4.17 SoTL1_Trigger
3.4.18 Ut_Trigger
3.4.19 VT_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 Body DB_Info_Utility
PACKAGE BODY DB_INFO_UTILITY AS
procedure check_archivelog_conf
SYSTEM_DB_INFO_NOTAVAILABLE EXCEPTION;
p_status_archivelog varchar2(13):=null;
p_CTM_archivelog_status varchar2(13):=null;
select upper(LOG_MODE) into p_status_archivelog from CTMANAGER.INFO_DB_TABLE;
select upper(ACTIVEVALUE) into p_CTM_archivelog_status from CTM_CONFIG_TABLE
where SECTIONNAME = 'database' and PROPERTYNAME = 'db-archivelog-enabled';
IF ( p_status_archivelog = 'NOARCHIVELOG' ) THEN
IF ( p_CTM_archivelog_status = 'TRUE' ) THEN
-- CTM Status wrong Archivelog not enabled
UPDATE CTM_CONFIG_TABLE SET ACTIVEVALUE = 'false' , PERMANENTVALUE = 'false'
WHERE SECTIONNAME = 'database' and PROPERTYNAME = 'db-archivelog-enabled';
IF ( p_CTM_archivelog_status = 'FALSE' ) THEN
-- CTM Status wrong Archivelog enabled
UPDATE CTM_CONFIG_TABLE SET ACTIVEVALUE = 'true' , PERMANENTVALUE = 'true'
WHERE SECTIONNAME = 'database' and PROPERTYNAME = 'db-archivelog-enabled';
raise SYSTEM_DB_INFO_NOTAVAILABLE;
3.1.2 Body Security_Pkg
CREATE OR REPLACE PACKAGE body security_pkg AS
PROCEDURE sysAdminEnable AS
UPDATE CTM_CONFIG_TABLE SET ACTIVEVALUE = 'true' WHERE PROPERTYNAME =
'sys-admin-enable';
PROCEDURE sysAdminDisable AS
UPDATE CTM_CONFIG_TABLE SET ACTIVEVALUE = 'false' WHERE PROPERTYNAME =
'sys-admin-enable';
3.1.3 Body Conversion_Utility
CREATE OR REPLACE PACKAGE BODY CONVERSION_UTILITY AS
function to_base( p_dec in number, p_base in number )
l_str varchar2(255) default NULL;
l_num number default p_dec;
l_hex varchar2(16) default '0123456789ABCDEF';
if ( p_dec is null or p_base is null )
if ( trunc(p_dec) <> p_dec OR p_dec < 0 ) then
l_str := substr( l_hex, mod(l_num,p_base)+1, 1 ) || l_str;
l_num := trunc( l_num/p_base );
p_from_base in number default 16 ) return number
l_hex varchar2(16) default '0123456789ABCDEF';
if ( p_str is null or p_from_base is null )
for i in 1 .. length(p_str) loop
l_num := l_num * p_from_base + instr(l_hex,upper(substr(p_str,i,1)))-1;
function to_hex( p_dec in number ) return varchar2
return to_base( p_dec, 16 );
function to_bin( p_dec in number ) return varchar2
return to_base( p_dec, 2 );
function to_oct( p_dec in number ) return varchar2
return to_base( p_dec, 8 );
3.1.4 Conversion_Utility
CREATE OR REPLACE PACKAGE CONVERSION_UTILITY AS
function to_base( p_dec in number, p_base in number )
p_from_base in number default 16 ) return number;
function to_hex( p_dec in number ) return varchar2;
function to_bin( p_dec in number ) return varchar2;
function to_oct( p_dec in number ) return varchar2;
3.1.5 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,
p_StrDirection IN varchar2,
p_StrLocation 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_StrDirection IN varchar2,
p_StrLocation 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,
p_StrDirection IN varchar2,
p_StrLocation 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 /*+ INDEX_FFS(ACTIVE_ALARM_PK) */ 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,
StrObjInstance = p_StrObjInstance
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;
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);
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''), activealarmflag=0,
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')';
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;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''), activealarmflag =2,
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')';
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;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''),
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')' ;
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-rows_processed
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
IF (p_activealarmseverity = 5) Then
SET NumMinorAlarms=NumMinorAlarms-rows_processed
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 6) THEN
SET NumMajorAlarms=NumMajorAlarms-rows_processed
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 7) THEN
SET NumCriticalAlarms=NumCriticalAlarms-rows_processed
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);
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''), activealarmflag=0,
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')';
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;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''), activealarmflag =2,
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')';
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;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS AM''
';
statement_txt:='Update active_alarm_table set
alarmstatus=1,clearalarmtimestamp=to_date('||''''||p_clearalarmtimestamp||''''||',
''MM/DD/YYYY HH:MI:SS AM''),
NEAlarmClearTimestamp=to_date('||''''||p_NEAlarmClearTimestamp||''''||', ''MM/DD/YYYY
HH:MI:SS AM'')' ;
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-rows_processed
WHERE linkid=p_linkid(table_row)
AND NumWarningAlarms > 0;
IF (p_activealarmseverity = 5) Then
SET NumMinorAlarms=NumMinorAlarms-rows_processed
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 6) THEN
SET NumMajorAlarms=NumMajorAlarms-rows_processed
WHERE linkid = p_linkid(table_row)
IF (p_activealarmseverity = 7) THEN
SET NumCriticalAlarms=NumCriticalAlarms-rows_processed
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,
p_StrDirection IN varchar2,
p_StrLocation 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,
p_AlarmInfoList(i).StrDirection,
p_AlarmInfoList(i).StrLocation
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.6 DB_Info_Utility
PACKAGE DB_INFO_UTILITY AS
procedure check_archivelog_conf;
3.1.7 getIPSLA_IPADDR
CREATE OR REPLACE function getIPSLA_IPADDR (VAR_NEID number,VAR_SLOTNUMBER number,VAR_BG
number) return VARCHAR2
and SLOT_NUMBER = VAR_SLOTNUMBER
and BRIDGE_GROUP_NUMBER = VAR_BG
and IP_ADDRESS is not null
and INTERFACE_TYPE = 190;
select MAX(IP_ADDRESS) into ipAddr
and SLOT_NUMBER = VAR_SLOTNUMBER
and BRIDGE_GROUP_NUMBER = VAR_BG
and IP_ADDRESS is not null
and INTERFACE_TYPE = 190;
3.1.8 getIPSLA_SUBNETMASK
CREATE OR REPLACE function getIPSLA_SUBNETMASK (VAR_NEID number,VAR_SLOTNUMBER
number,VAR_BG number) return VARCHAR2
and SLOT_NUMBER = VAR_SLOTNUMBER
and BRIDGE_GROUP_NUMBER = VAR_BG
and SUBNET_MASK is not null
and INTERFACE_TYPE = 190;
select MAX(SUBNET_MASK) into subNetMask
and SLOT_NUMBER = VAR_SLOTNUMBER
and BRIDGE_GROUP_NUMBER = VAR_BG
and SUBNET_MASK is not null
and INTERFACE_TYPE = 190;
3.1.9 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.10 Prune_Package
3.1.10.1 Prune_Package for Small Configurations
rem Pruning Package and change prune schedule package
CREATE OR REPLACE PACKAGE Prune AS
rows_to_be_deleted NUMBER := 100000 ;
ORACLE_BASE varchar2(20);
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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Starting
prune auditlog at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Prune
transaction log table before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(TRANSACTION_LOG_TS_I) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','Deleted
'||rows_processed||' rows from transaction_log_table');
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Starting
prune errorlog at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Prune error
log table data before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(ERROR_LOG_TIME_INDEX) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','Deleted
'||rows_processed||' rows from error_log_table ');
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_errorlog.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/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;
TYPE ackwid_tab is TABLE OF NUMBER(10,0) INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Starting
prune fm at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Prune
FM data before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(ALARM_EVENT_TIME_INDEX) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from alarm_event_table at '|| sysdate);
FOR i IN (select /*+ INDEX_FFS(ACTIVE_ALARM_TIME_INDEX) */ ackindex, rowid from
ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and rownum <= rows_to_be_deleted) LOOP
rowid_tab_v(counter) := i.rowid;
ackwid_tab_v(counter) := i.ackindex;
IF counter = rows_to_be_deleted THEN
FOR rid IN 1 .. counter LOOP
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
WHERE ackindex = ackwid_tab_v(rid) AND ackindex <> -1;
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FOR rid IN 1 .. counter LOOP
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
WHERE ackindex = ackwid_tab_v(rid) AND ackindex <> -1;
rows_processed:=rows_processed+counter;
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from active_alarm_table at '||sysdate);
FOR i IN (select /*+ INDEX_FFS(SYSLOG_MESSAGE_TS_I) */ rowid from
SYSLOG_MESSAGE_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 SYSLOG_MESSAGE_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 SYSLOG_MESSAGE_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from SYSLOG_MESSAGE_TABLE at '|| sysdate);
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Starti
ng prune server monitor table at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Prune
server monitor table before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(SERVER_MONITOR_TIME_I) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','Delete
d '||rows_processed||' rows from SERVER_MONITOR_TABLE at '|| sysdate);
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_servermonitor.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Starti
ng prune admin job table at '||sysdate);
append_file(ORACLE_BASE||'admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Prune
admin job table before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(admin_job_ScheduledTIme_index) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Delete
d '||rows_processed||' rows from ADMIN_JOB_TABLE at '|| sysdate);
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error
in prune admin job table '||SQLERRM||', '||SQLCODE);
3.1.10.2 prune_package for Medium, Large, and High-End Configurations
CREATE OR REPLACE PACKAGE Prune AS
rows_to_be_deleted NUMBER := 100000 ;
ORACLE_BASE varchar2(20);
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_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;
ORACLE_BASE varchar2(20);
err_file := 'prune_'||p_table_name||'.err';
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:= sysdate-intervaldays;
append_file(ORACLE_BASE||'/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%'
/* get the counter of rows to be pruned */
cursor_handle_1 := DBMS_SQL.OPEN_CURSOR;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
statement_txt_1 := 'SELECT /*+ INDEX_FFS('||rec.index_name||') */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump',log_file,'pruned
'||deleted_rows||' from '||rec.table_name);
DBMS_SQL.CLOSE_CURSOR (cursor_handle_1);
/* prune partitions before the prune intervaldays */
FOR i IN ( SELECT partition_name FROM user_segments
Where to_date(substr(partition_name,2,9), 'MMDDYYYY') <=
prunedate
AND segment_name=rec.table_name)
/* drop all the old partition */
--dbms_output.put_line(i.partition_name);
cursor_handle := DBMS_SQL.OPEN_CURSOR;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
statement_txt := 'alter table '||rec.table_name ||' drop partition
'||i.partition_name ||' UPDATE INDEXES ';
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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump',log_file,'dropped
partition '||i.partition_name||' from '||rec.table_name);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump',log_file,'prune
'||p_table_name||' successfully finished at '||sysdate);
create_file(ORACLE_BASE||'/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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_auditlog.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
create_file(ORACLE_BASE||'/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;
TYPE ackwid_tab is TABLE OF NUMBER(10,0) INDEX BY BINARY_INTEGER;
rows_processed number :=0;
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:= sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Starting
prune fm at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Prune
FM data before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(ALARM_EVENT_TIME_INDEX) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from alarm_event_table at '|| sysdate);
FOR i IN (select /*+ INDEX_FFS(ACTIVE_ALARM_TIME_INDEX) */ ackindex, rowid from
ACTIVE_ALARM_TABLE
where ActiveAlarmTimeStamp < prunedate
and rownum <= rows_to_be_deleted) LOOP
rowid_tab_v(counter) := i.rowid;
ackwid_tab_v(counter) := i.ackindex;
IF counter = rows_to_be_deleted THEN
FOR rid IN 1 .. counter LOOP
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
WHERE ackindex = ackwid_tab_v(rid) AND ackindex <> -1;
rows_processed:=rows_processed+counter;
IF counter < rows_to_be_deleted THEN
FOR rid IN 1 .. counter LOOP
DELETE FROM ACTIVE_ALARM_TABLE
WHERE rowid = rowid_tab_v(rid);
WHERE ackindex = ackwid_tab_v(rid) AND ackindex <> -1;
rows_processed:=rows_processed+counter;
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from active_alarm_table at '||sysdate);
FOR i IN (select /*+ INDEX_FFS(SYSLOG_MESSAGE_TS_I) */ rowid from
SYSLOG_MESSAGE_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 SYSLOG_MESSAGE_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 SYSLOG_MESSAGE_TABLE
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','Deleted
'||rows_processed||' rows from SYSLOG_MESSAGE_TABLE at '|| sysdate);
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_fm.err','Error in
pruning fm log '||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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Starti
ng prune admin job table at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Prune
admin job table before '||prunedate) ;
FOR i IN (select /*+ INDEX_FFS(admin_job_ScheduledTIme_index) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','Delete
d '||rows_processed||' rows from ADMIN_JOB_TABLE at '|| sysdate);
append_file(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_adminjobtable.err','Error
in prune admin job table '||SQLERRM||', '||SQLCODE);
3.1.10.3 Prune_TCA_Event
create or replace PROCEDURE prune_tca_event( intervaldays IN number ) AS
rows_processed number:=0;
TYPE rowid_tab is TABLE OF ROWID INDEX BY BINARY_INTEGER;
ORACLE_BASE varchar2(20);
rows_to_be_deleted number:=100000;
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
prunedate:=sysdate-intervaldays;
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.log','Starting
prune TCA EVENTs at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.log','Prune TCA
EVENT table before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(TCA_EVENT_TS_I) */ rowid from tca_event_table
where NEEVENTTIMESTAMP < 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 tca_event_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 tca_event_table
WHERE rowid = rowid_tab_v(rid);
rows_processed:=rows_processed+counter;
dbms_output.put_line('Deleted '||rows_processed||' rows from
tca_event_table');
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.log','Deleted
'||rows_processed||' rows from tca_event_table');
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.log','Finish
prune TCA EVENT table at '||sysdate);
dbms_output.put_line('user choose to keep all tca event data, so no prune at
this time');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_tcaevent.err','Error in
pruning tca event '||SQLERRM||', '||SQLCODE);
3.1.11 Security_Pkg
CREATE OR REPLACE PACKAGE security_pkg as
type security_tab_type is table of rowid index by binary_integer;
security_tab security_tab_type;
security_index binary_integer;
procedure sysAdminEnable;
procedure sysAdminDisable;
3.1.12 Service_Availability
create or replace package service_availability as
procedure service_activated (instance_name IN VARCHAR2);
procedure service_deactivated (instance_name IN VARCHAR2);
procedure service_crashed (instance_name IN VARCHAR2);
procedure service_restarted (instance_name IN VARCHAR2);
procedure prune (intervaldays IN NUMBER);
end service_availability;
package body service_availability AS
PROCEDURE service_activated (instance_name IN VARCHAR2) AS
-- INSERTING into SERVICE_AVAILABILITY_TABLE
Insert into "SERVICE_AVAILABILITY_TABLE"
("SERVICE_INSTANCE_NAME","STATUS","FIRST_ACTIVATED","LAST_CRASH","RUNNING_SINCE","PAST_UPT
IME","DEACTIVATED","PERC_UPTIME") values (instance_name,1,sysdate,null,sysdate,0,null,0);
PROCEDURE service_deactivated (instance_name IN VARCHAR2) AS
past_uptime_var number:=0;
perc_uptime_var number:=0;
first_activated_var date;
SELECT PAST_UPTIME into past_uptime_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name AND
SELECT FIRST_ACTIVATED into first_activated_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name AND (STATUS=1 OR STATUS=2);
SELECT RUNNING_SINCE into running_since_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name
AND (STATUS=1 OR STATUS=2);
past_uptime_var:=TIME_DIFF(running_since_var,sysdate) + past_uptime_var;
perc_uptime_var:=(past_uptime_var/(TIME_DIFF(first_activated_var,sysdate)))*100;
--append_file('/temp','time_diff.log','past_uptime '||past_uptime_var);
UPDATE SERVICE_AVAILABILITY_TABLE SET STATUS=0, PAST_UPTIME=past_uptime_var,
DEACTIVATED=sysdate,
PERC_UPTIME=perc_uptime_var where SERVICE_INSTANCE_NAME=instance_name AND (STATUS=1 OR
STATUS=2);
PROCEDURE service_crashed (instance_name IN VARCHAR2) AS
past_uptime_var number:=0;
perc_uptime_var number:=0;
first_activated_var date;
SELECT PAST_UPTIME into past_uptime_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name AND
SELECT FIRST_ACTIVATED into first_activated_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name AND STATUS=1;
SELECT RUNNING_SINCE into running_since_var FROM SERVICE_AVAILABILITY_TABLE where
SERVICE_INSTANCE_NAME=instance_name
past_uptime_var:=TIME_DIFF(running_since_var,sysdate) + past_uptime_var;
--append_file('/temp','time_diff.log','past_uptime '||past_uptime_var);
UPDATE SERVICE_AVAILABILITY_TABLE SET STATUS=2, LAST_CRASH=sysdate,
PAST_UPTIME=past_uptime_var where
SERVICE_INSTANCE_NAME=instance_name AND STATUS=1;
PROCEDURE service_restarted (instance_name IN VARCHAR2) AS
UPDATE SERVICE_AVAILABILITY_TABLE SET STATUS=1, RUNNING_SINCE=sysdate where
SERVICE_INSTANCE_NAME=instance_name AND STATUS=2;
PROCEDURE prune (intervaldays IN NUMBER) IS
ORACLE_BASE varchar2(20);
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
LOGDIR := ORACLE_BASE|| '/admin/' || ORACLE_SID || '/udump';
LOGFILE := 'prune_sa.log';
create_file(LOGDIR, LOGFILE,'Starting prune service availability at '||sysdate);
IF ( intervaldays > 0) THEN
append_file(LOGDIR, LOGFILE,'prune service availability data before '||prunedate);
prunedate:=sysdate-intervaldays;
SELECT count(*) into cnt FROM SERVICE_AVAILABILITY_TABLE where STATUS=0 AND
DEACTIVATED<prunedate;
DELETE FROM SERVICE_AVAILABILITY_TABLE where STATUS=0 AND DEACTIVATED<prunedate;
append_file(LOGDIR, LOGFILE,'Deleted '||cnt||' rows.');
append_file(LOGDIR,LOGFILE,'Invalid interval '||intervaldays);
END service_availability;
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);
ORACLE_BASE varchar2(20);
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
create_file(ORACLE_BASE||'/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',
'TRANSACTION_LOG_TABLE','SYSLOG_MESSAGE_TABLE',
'NE_AUDIT_TRAIL_TABLE', 'ONS158XX_LAC_LOG_TABLE'
/* define date range for the partition to be added */
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');
/* add the new partition */
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||' UPDATE INDEXES ';
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('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_log_partition.log','added
partition '||partition_to_be_added||' to '||rec.table_name);
append_file('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_log_partition.log',rec.table_
name||' already has log partitions for the next 3 days');
append_file('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_log_partition.log','Adding
partition successfully finished at '||sysdate);
create_file('/ORACLE_BASE/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);
ORACLE_BASE varchar2(20);
pm_service_enabled varchar2(15);
rows_services number := 0;
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
create_file(ORACLE_BASE||'/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')
FOR rec IN ( SELECT DISTINCT ust.table_name FROM user_tables ust ,
pmservice_associated_tab_table pm WHERE ust.table_name = pm.table_name AND pm.service_type
<> 'NONE')
rows_services := rows_services + 1;
/* define date range for the partition to be added */
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',rec.table_
name||' processing.....');
Select max(to_date( substr(partition_name,2,9),'MMDDYYYY')),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
CURSOR pm_service_curs IS select table_name, service_type from
PMSERVICE_ASSOCIATED_TAB_TABLE where table_name = rec.table_name;
pmserv_rec pm_service_curs%ROWTYPE;
FOR pmserv_rec IN pm_service_curs
select activevalue INTO pm_service_enabled
where sectionname = pmserv_rec.service_type and propertyname ='pm-service';
exit when pm_service_enabled = 'active';
IF (pm_service_enabled ='active' and add_flag=1) THEN
append_file('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',rec.table_n
ame||' PM Service associated ACTIVE');
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');
/* add the new partition */
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)'
|| ')'|| ' UPDATE INDEXES ';
--DBMS_OUTPUT.PUT_LINE(statement_txt);
append_file('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',' DDL
command = '||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('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','added
partition '||partition_to_be_added||' to '||rec.table_name);
append_file('/ORACLE_BASE/admin/'||ORACLE_SID||'/udump','add_pm_partition.log',rec.table_n
ame||' already has partitions for the next 3 days');
append_file('/ORACLE_BASE/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');
IF (rows_services = 0) THEN
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','Error in
adding partition caused by problem on configuration table ');
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','add_pm_partition.log','Adding
partition successfully finished at '||sysdate);
create_file(ORACLE_BASE||'/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,
isIpV6 IN number default 0,
preprovisioned_ip IN number default 4,
OperationalState IN number,
NeDescription IN varchar2,
SnmpCommunityString IN varchar2,
DisplayModelName IN varchar2,
GwTL1UserName IN varchar2,
GwTL1Password IN varchar2,
pmCollectionFlag IN number,
inNeSnmpUname IN varchar2,
inNeSnmpAuthProt IN varchar2,
inNeSnmpAuthPwd IN varchar2,
inNeSnmpPrivPwd IN varchar2,
i_subNWName varchar2(64);
i_addnewsubnet number:=0;
BulkNeAdd_FAILED EXCEPTION;
NtwPartitionLimit_EXCEEDED EXCEPTION;
i_NtwPartitionLimit number :=0;
i_ActualNEsInNPID number :=0;
-- create_file('/oracle','bulkneadd.log','neid:'||neId||'
newGroupId:'||newGroupId||' NeModelType:'||NeModelType||' subNwname:'||subNwname||'
subNwId:'||subNwId||' GneId:'||GneId);
IF ((NeModelType = 3) OR (NeModelType = 14) OR (NeModelType = 18) OR
(NeModelType = 30) OR (NeModelType = 32) ) THEN
IF ((NeModelType = 14) OR (NeModelType = 30) OR (NeModelType = 32) OR
(NeModelType = 39)) THEN
select to_number(activevalue) into i_NtwPartitionLimit from
ctm_config_table
where sectionname = 'ons15454sdh-net' and propertyname = 'net-threshold';
select to_number(activevalue) into i_NtwPartitionLimit from
ctm_config_table
where sectionname = 'ons15454-net' and propertyname = 'net-threshold';
select count(*) into i_ActualNEsInNPID from ne_info_table ne,
subnetwork_table sub
where ne.NESubNetworkID=sub.subnetID and sub.NPID=NWPartitionId and
ne.nemodeltype = NeModelType;
-- append_file('/oracle','bulkneadd.log',' NEs Actuals = '||
i_ActualNEsInNPID || ' NEsLimit = ' || i_NtwPartitionLimit );
IF ((i_ActualNEsInNPID +1) > i_NtwPartitionLimit ) THEN
-- append_file('/oracle','bulkneadd.log',' RAISE EXCEPTION' );
raise NtwPartitionLimit_EXCEEDED;
SELECT NEDBACCESSID_SEQ.nextval INTO i_neid FROM dual;
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,i_neid,'',GroupingOption,GroupPrefix, inUserId);
i_addnewsubnet:= SubNWToBeInserted;
IF (i_addnewsubnet = 0) THEN
SELECT count(*) INTO counter from subnetwork_table WHERE subnetid=SubNwId;
IF (i_addnewsubnet = 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);
INSERT INTO ne_info_table
(NEDBAccessID, NESysID, NEIPAddr, NEIPV6Addr, IS_IPV6, PREPROVISIONED_IP, NENSAPAddr,
NEState, isNEConnected, GNEID, NEDescription, NEConfigMode, NESnmpCommString, NECLLICode,
NEStateChangeTime, NEModelType, NEModelIndex, NEModelStatus, NESubNetworkID, NETimeOffset,
NELEDStatus, NESystemTitle,NEUserLabel, NEVendorName, NEVersion,
NENumActiveCriticalErrors, NENumActiveMajorErrors, NENumActiveMinorErrors, NEPmEnabled,
NENodeID, NEInventoryLastChanged, NESubnetMask, NEDefaultGateway,
NENumUnActiveCriticalErrors, NENumUnActiveMajorErrors, NENumUnActiveMinorErrors,
NENumCleared, DisplayModelName, GWTL1USERNAME, GWTL1PASSWD, ServiceID, DeleteState,
ConfigSyncStatus, NEUSERNAME, NEUSERPASSWORD, NEDiscoveryState, NERobustPmEnabled,
SecurityTicket, RobustPMEnableTime, DebugLevel, Robust1DayPMEnableTime, SecondsBehindUTC,
SecondsDstBehindUTC, NESNGRPID, NEAliasID, IsMultiShelf, RoleType, NEVirtualIpAddr,
IsTunnelRequired, NE_SNMP_UNAME, NE_SNMP_VERSION, NE_SNMP_AUTH_PROT, NE_SNMP_AUTH_PWD,
NE_SNMP_PRIV_PWD, NE_SNMP_EID, IsDSS)
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);
WHEN NtwPartitionLimit_EXCEEDED THEN
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
p_statement_txt in varchar2
pragma AUTONOMOUS_TRANSACTION;
execute immediate p_statement_txt;
CREATE or REPLACE TRIGGER act_trigger AFTER INSERT on network_partition_table
partition_to_be_added varchar2(15);
statement_txt varchar2(500);
partition_to_be_added := 'P_NP_'||:new.NPId;
statement_txt := 'alter table circuit_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_bs_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_ctp_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_span_bs_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_dest_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_span_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_vlan_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_vcg_tbl add partition ' ||
partition_to_be_added || ' values(' || :new.NPId ||
') tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
TRIGGER NEINFO_TRIGGER AFTER INSERT ON NE_INFO_TABLE
partition_to_be_added varchar2(15);
statement_txt varchar2(500);
select permanentvalue into config from ctm_config_table where sectionname='database' and
propertyname='db-server-configuration';
if (config !='small') then
if ( :new.nemodeltype not in (24,33,34,28 )) then
select count(*) into flag from user_tab_partitions where table_name='CIRCUIT_TBL' and
partition_name = 'P_NP_1' ;
partition_to_be_added := 'P_NP_1';
statement_txt := 'alter table circuit_tbl add partition ' || partition_to_be_added || '
values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_bs_tbl add partition ' || partition_to_be_added
|| ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_ctp_tbl add partition ' || partition_to_be_added
|| ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_span_bs_tbl add partition ' ||
partition_to_be_added || ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_dest_tbl add partition ' ||
partition_to_be_added || ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_span_tbl add partition ' ||
partition_to_be_added || ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_vlan_tbl add partition ' ||
partition_to_be_added || ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(statement_txt);
statement_txt := 'alter table circuit_vcg_tbl add partition ' || partition_to_be_added
|| ' values(1) tablespace BASE_DATA_TABLESPACE'||' UPDATE INDEXES ';
execute_dml_statement(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 GET_NESYSID
CREATE OR REPLACE FUNCTION GET_NESYSID(neId IN NUMBER)
select nesysid into retVal from ne_info_table where nedbaccessid = neId;
3.2.12 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.13 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.14 Prune_Audittrail
3.2.14.1 Prune_Audittrail Procedure for Small Configurations
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 ;
ORACLE_BASE varchar2(20);
SELECT activevalue INTO ORACLE_SID
WHERE sectionname='database' and propertyname='dbname';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
IF ( intervaldays != -1 ) THEN
execute immediate 'alter session set nls_date_format = ''MM/DD/YYYY HH:MI:SS
AM'' ';
prunedate:=to_char(sysdate-intervaldays,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('Prune data before '||prunedate);
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Starting
prune audittrail at '||sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Prune
audit trail table before '||prunedate);
FOR i IN (select /*+ INDEX_FFS(NE_AUDIT_TRAIL_TS_I) */ 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Deleted
'||rows_processed||' rows from NE_Audit_Trail_Table at '|| sysdate);
append_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','Finish
prune audittrail at '||sysdate);
FOR i IN (select /*+ INDEX_FFS(ONS158XX_LACLOG_TIMESTAMP_I) */ 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(ORACLE_BASE||'/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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.log','User
choose to keep all data, no prune');
create_file(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_audittrail.err','Error in
audit trail log '||SQLERRM||', '||SQLCODE);
3.2.14.2 prune_audittrail Procedure for Medium, Large, and High-End Configurations
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;
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_audittrail.log','Starting
prune audittrail at '||sysdate);
prune.prune_log('NE_AUDIT_TRAIL_TABLE', intervaldays, 'prune_audittrail.log');
prune.prune_log('ONS158XX_LAC_LOG_TABLE', intervaldays,
'prune_audittrail.log');
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.15 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);
ORACLE_BASE varchar2(20);
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';
SELECT activevalue INTO ORACLE_BASE
WHERE sectionname='database' and propertyname='db-oracle-base';
/* Check if this ne is a GNE and if it has nes */
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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Ca
n 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(ORACLE_BASE||'/admin/'||ORACLE_SID||'/udump','prune_ne'||p_nesysid||'.log','Pr
ocess prune '||p_nesysid||' at '||prune_date);
/* get the nedbaccessid from nesysid */
SELECT nedbaccessid, nenodeid INTO p_nedbaccessid, p_nenodeid
/* get a list of table name that has nedbaccessid column from data dictionary
|| and prune data from each table
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') AND
a.table_name NOT LIKE 'BIN$%')
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;
-- purge all circuit tables based on cktnodeid
IF (i.column_name='CKTNODEID' ) THEN
statement_txt := 'DELETE FROM '||i.table_name ||' Where
cktnodeid = '||p_nenodeid ||
' AND rownum < = '||rows_deleted;
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(ORACLE_BASE||'/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;