~~~BEGIN_MAIN_SECTION~~~
[PRODUCT]
procedure=UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB
table=ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB
table=ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB
job=UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB_JOB
~~~END_MAIN_SECTION~~~

~~~BEGIN_VERSION_SECTION~~~
[VERSION]
version=2025-11-04

[SQL_SCRIPT___DEFAULT]
CREATE TABLE "OTHQ_OWN"."ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB" 
   (	"MONTH_MINUTES" NUMBER, 
	"ATP_CMIS" NUMBER, 
	"ATP_PLATFORM_UPTIME" VARCHAR2(41 BYTE) COLLATE "USING_NLS_COMP", 
	"EXA_CMIS" NUMBER, 
	"EXA_PLATFORM_UPTIME" VARCHAR2(41 BYTE) COLLATE "USING_NLS_COMP", 
	"ATP_SLC_BREAK" NUMBER, 
	"ATP_EXPOSED_CREDITS" NUMBER, 
	"EXA_SLC_BREAK" NUMBER, 
	"EXA_EXPOSED_CREDITS" NUMBER, 
	"MONTH" DATE, 
	"ATP_CNT" NUMBER, 
	"EXA_CNT" NUMBER, 
	"CASES_ATP" NUMBER, 
	"CASES_EXACS" NUMBER, 
	"CIM_ATP" NUMBER, 
	"CIM_EXACS" NUMBER, 
	"X0_ATP_CNT" NUMBER, 
	"X0_ATP_PERCENTAGE" NUMBER, 
	"X0_ATP_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X0_ATP_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X1_ATP_CNT" NUMBER, 
	"X1_ATP_PERCENTAGE" NUMBER, 
	"X1_ATP_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X1_ATP_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X2_ATP_CNT" NUMBER, 
	"X2_ATP_PERCENTAGE" NUMBER, 
	"X2_ATP_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X2_ATP_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X3_ATP_CNT" NUMBER, 
	"X3_ATP_PERCENTAGE" NUMBER, 
	"X3_ATP_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X3_ATP_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X4_ATP_CNT" NUMBER, 
	"X4_ATP_PERCENTAGE" NUMBER, 
	"X4_ATP_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X4_ATP_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X0_EXA_CNT" NUMBER, 
	"X0_EXA_PERCENTAGE" NUMBER, 
	"X0_EXA_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X0_EXA_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X1_EXA_CNT" NUMBER, 
	"X1_EXA_PERCENTAGE" NUMBER, 
	"X1_EXA_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X1_EXA_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X2_EXA_CNT" NUMBER, 
	"X2_EXA_PERCENTAGE" NUMBER, 
	"X2_EXA_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X2_EXA_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X3_EXA_CNT" NUMBER, 
	"X3_EXA_PERCENTAGE" NUMBER, 
	"X3_EXA_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X3_EXA_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X4_EXA_CNT" NUMBER, 
	"X4_EXA_PERCENTAGE" NUMBER, 
	"X4_EXA_PERCENTAGE1" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"X4_EXA_PERCENTAGE2" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP"
   );


[SQL_SCRIPT___DEFAULT]

CREATE TABLE "OTHQ_OWN"."ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB" 
   (	"P_START" DATE, 
	"INACTIVE" NUMBER, 
	"DCID" VARCHAR2(16 BYTE) COLLATE "USING_NLS_COMP", 
	"ACCOUNTTYPE" VARCHAR2(16 BYTE) COLLATE "USING_NLS_COMP", 
	"CATEGORY" VARCHAR2(32 BYTE) COLLATE "USING_NLS_COMP", 
	"TOP200" NUMBER, 
	"UP" NUMBER, 
	"DOWN" NUMBER, 
	"UPTIME" NUMBER
   );



[SQL_SCRIPT___DEFAULT]
CREATE OR REPLACE PROCEDURE UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB AUTHID CURRENT_USER
IS
begin
	begin EXECUTE IMMEDIATE q'!delete from ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB where MONTH>=TRUNC(ADD_MONTHS(SYSDATE, -2),'MM')!';end;commit;
	begin EXECUTE IMMEDIATE q'!delete from ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB where P_START>=TRUNC(ADD_MONTHS(SYSDATE, -2),'MM')!';end;commit;
	begin EXECUTE IMMEDIATE q'!insert into ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB (select * from ON_DEMAND_SODC_DOWNTIME_PRE4_TB where MONTH>=TRUNC(ADD_MONTHS(SYSDATE, -2),'MM'))!';end;commit;
	begin EXECUTE IMMEDIATE q'!insert into ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB (select * from ON_DEMAND_SODC_DOWNTIME_TB where P_START>=TRUNC(ADD_MONTHS(SYSDATE, -2),'MM'))!';end;commit;
	commit;
end;

[SQL_SCRIPT___DEFAULT]
begin EXECUTE IMMEDIATE 'begin dbms_scheduler.drop_job(job_name => ''UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB_JOB'');end;';exception WHEN OTHERS THEN NULL;end;


[SQL_SCRIPT___DEFAULT]

begin
    dbms_scheduler.create_job(job_name        => 'UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB_JOB',
                              job_type        => 'STORED_PROCEDURE',
                              job_action      => 'UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB',
                              start_date      => systimestamp,
                              end_date        => null,
                              repeat_interval => 'freq=hourly; interval=1;',
                              enabled         => true,
                              auto_drop       => false,
                              comments        => 'Run UPDATE_ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB procedure.');
end;

~~~END_VERSION_SECTION~~~




/*
REDO SNAPSHOTS! WILL DESTROY SNAPSHOT DATA!!!

delete from ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB;
delete from ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB;
ANALYZE TABLE ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB DELETE STATISTICS;
ANALYZE TABLE ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB DELETE STATISTICS;
insert into ON_DEMAND_SODC_DOWNTIME_PRE4_SNAPSHOT_TB (select * from ON_DEMAND_SODC_DOWNTIME_PRE4_TB);
insert into ON_DEMAND_SODC_DOWNTIME_SNAPSHOT_TB (select * from ON_DEMAND_SODC_DOWNTIME_TB);
*/