-- SRPD Fixes
-- Get wnas records for new statistics

   insert into wnas
   select
   seq_wnas.nextval,
   'SRP2',
   'BEGIN SRP2TODAY;  END;',
   (select count(*) from wnas)+1,
   0
   from dual
   where exists (select 1 from wnas where upper(wnas_name) like '%SRPD%') and 
   not exists (select 1 from wnas where upper(wnas_name) like '%SRP2%');
   
   commit;


-- fill srp2

insert into srp2
select 
seq_srp2.nextval,
srpd_date,
srpd_zdco_id,
srpd_netrev_d,
srpd_grossrev_d,
srpd_netrev_m,
srpd_grossrev_m,
srpd_netrev_y,
srpd_grossrev_y,
srpd_partner_id,
0,
srpd_wphs_id,
srpd_zdco_longdesc,
srpd_zdco_numericdesc,
srpd_zdcg_longdesc,
srpd_zdco_cdt,
srpd_type
from srpd
where SRPD.SRPD_DATE>=to_date('01.01.2010','dd.mm.yyyy');

commit;


-- delete not correct SRPD value

delete from srpd where srpd_type<>0;

commit;


-- SRDS Fixes
-- Get wnas records for new statistics

insert into wnas
   select
   seq_wnas.nextval,
   'SRD2',
   'BEGIN SRD2TODAY;  END;',
   (select count(*) from wnas)+1,
   0
   from dual
   where exists (select 1 from wnas where upper(wnas_name) like '%SRDS%') and 
   not exists (select 1 from wnas where upper(wnas_name) like '%SRD2%');
   
commit;


-- fill srd2

insert into srd2
select 
seq_srd2.nextval,
srds_date,
srds_zdco_id,
srds_ycad_id,
srds_netrev_d,
srds_grossrev_d,
srds_netrev_m,
srds_grossrev_m,
srds_netrev_y,
srds_grossrev_y,
srds_partner_id,
0,
srds_wphs_id,
srds_zdco_longdesc,
srds_zdco_numericdesc,
srds_zdcg_longdesc,
srds_zdco_cdt,
srds_type
from srds
where SRDS.SRDS_DATE>=to_date('01.01.2010','dd.mm.yyyy');

commit;


-- delete not correct SRDS value

delete from srds where srds_type<>0;

commit;
