create procedure "npmuser".super_busy_cell(s_time datetime year to second)
SET DEBUG FILE TO '/tmp/superbusycell.log';
TRACE 'BEGIN 24h traff';
TRACE ON;
delete from super_busy_cell where first_result=s_time;
delete from busy_cell where first_result=s_time;
delete from idle_cell where first_result=s_time;
delete from heavy_ovfl_cell where first_result=s_time;
delete from ovfl_cell where first_result=s_time;
delete from worst_cell where first_result=s_time;
insert into super_busy_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.super_busy_cell=1;
insert into busy_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.busy_cell=1;
insert into idle_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.idle_cell=1;
insert into heavy_ovfl_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.heavy_ovfl_cell=1;
insert into ovfl_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.ovfl_cell=1;
insert into worst_cell(ne_id,first_result,cell_id,avail_tch_nbr,radio_capacity,
tch_traffic,tch_traffic_h,tch_nbr,drop_call_tch,tch_seize_nho,vendor_id)
select b.region_id,a.first_result,a.ne_id,a.avail_tch_nbr,
decode(c.trx_nbr,0,0,1,2.28,2,8.25,3,14.04,4,21.04,5,27.04,34.68),
a.tch_traffic,a.tch_traffic_h,a.tch_nbr,a.drop_call_tch,a.tch_seize_nho,b.vendor_id
from tpc_unic_bts_ne a,tcc_ne_snap b,tcc_bts c
where a.first_result=s_time
and extend(s_time,year to day)=b.compress_date
and b.compress_date=c.compress_date
and b.ne_type=300
and a.ne_id=b.ne_id
and b.ne_id=c.ne_id
and a.worst_cell=1;
end procedure;