邪恶八进制信息安全团队技术讨论组's Archiver

ring04h 2006-3-14 12:59

[转载]Informix存储过程示例

<P>信息来源:邪恶八进制信息安全团队</P>
<DIV>
<DIV>create procedure "npmuser".chk_grade(s_time datetime year to second)</DIV>
<DIV> define v_ne_id integer;<BR> define v_ne_type integer;<BR> define v_time datetime year to second;<BR> define v42 float;<BR> define v66 float;<BR> define v45 float;<BR> define v43 float;<BR> define v65 float;<BR> define v411 float;<BR> define v67 float;<BR> define f42 float;<BR> define f66 float;<BR> define f45 float;<BR> define f43 float;<BR> define f65 float;<BR> define f411 float;<BR> define f67 float;</DIV>
<DIV> SET DEBUG FILE TO '/tmp/chk_grade.log';<BR> TRACE 'BEGIN 24h traff';<BR> TRACE ON;</DIV>
<DIV> delete from chk_grade where first_result=s_time;</DIV>
<DIV> insert into chk_grade(ne_id,ne_type,first_result,g42,<BR> g66,g45,g43,g65,g411,g67)<BR> select<BR> TPA_UNIC_MSC_SUM.ne_id,TPA_UNIC_MSC_SUM.ne_type,TPA_UNIC_MSC_SUM.first_result,<BR> (SFB_DIVFLOAT_1((NVL(TPA_UNIC_MSC_SUM.SEND_IAI_MSG_NHO,0)+NVL(TPA_UNIC_MSC_SUM.VOICE_PAGING_<BR>REQ,0)),(TPA_UNIC_BTS_SUM.TCH_SEIZE_NHO*SFB_DIVFLOAT_1(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,(NVL<BR>(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,0)+NVL(TPA_UNIC_MSC_SUM.RECE_CALLCONFIRM_MSG,0)),0,0)+NVL(<BR>TPA_UNIC_MSC_SUM.RECE_IAI_MSG_NHO,0)),0,0)*(SFB_DIVFLOAT_1(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,<BR>(NVL(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,0)+NVL(TPA_UNIC_MSC_SUM.RECE_CALLCONFIRM_MSG,0)),0,0)*<BR>SFB_DIV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SUM.RECE_CALLCONFIRM_MSG,0)),0,0))*SFB_DIVFLO<BR>AT_1(NVL (TPA_UNIC_MSC_SUM.PAGING_RESP,0),NVL(TPA_UNIC_MSC_SUM.PAGING_REQ,0),0,0)*SFB_DIVFLOAT_1(TPA<BR>_UNIC_BTS_SUM.TCH_SEIZE_NHO,TPA_UNIC_BTS_SUM.TCH_CALL_REQ_NHO,0,0))*100,<BR> (SFB_DIVFLOAT_1((NVL(TPA_UNIC_MSC_SUM.SEND_IAI_MSG_NHO,0)+NVL(TPA_UNIC_MSC_SUM.VOICE_PAGING_<BR>REQ,0)+NVL(TPA_UNIC_MSC_SUM.LOSE_NUM_USER_BUSY_CALLED,0)),(TPA_UNIC_BTS_SUM.TCH_SEIZE_NHO*(SFB_DIVFL<BR>OAT_1(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,(NVL(TPA_UNIC_MSC_SUM.SEND_CALLPROCEEDING_MSG,0)+NVL(<BR>TPA_UNIC_MSC_SUM.RECE_CALLCONFIRM_MSG,0)),0,0))+NVL(TPA_UNIC_MSC_SUM.RECE_IAI_MSG_NHO,0)-(NVL(TPA_UN<BR>IC_MSC_SUM.ROUTING_QUERY_REQ,0)-NVL(TPA_UNIC_MSC_SUM.ROUTING_QUERY_SUC,0))),0,0))*100 , <BR> NVL(SFB_DIVFLOAT_1(TPA_UNIC_BTS_SUM.DROP_CALL_TCH,TPA_UNIC_BTS_SUM.TCH_SEIZE_NHO,0,0)*100,0)<BR>, <BR> NVL(SFB_DIVFLOAT_1(TPA_UNIC_MSC_SUM.PAGING_RESP,TPA_UNIC_MSC_SUM.PAGING_REQ,0,0)*100,0),<BR> NVL(SFB_DIVFLOAT_1(TPA_UNIC_BTS_SUM.WORST_CELL,TPA_GSMA_UNIC_SUM.TOTAL_CELL,0,0)*100,0) <BR> from tpa_unic_msc_sum tpa_unic_msc_sum,tpa_unic_bts_sum tpa_unic_bts_sum,tpa_gsma_unic_sum t<BR>pa_gsma_unic_sum<BR> where tpa_unic_msc_sum.first_result=tpa_unic_bts_sum.first_result<BR> and tpa_gsma_unic_sum.first_result=tpa_unic_bts_sum.first_result<BR> and tpa_unic_msc_sum.ne_id=tpa_unic_bts_sum.ne_id<BR> and tpa_gsma_unic_sum.ne_id=tpa_unic_bts_sum.ne_id<BR> and tpa_unic_bts_sum.ne_type in (10000,10003)<BR> and tpa_unic_msc_sum.first_result=s_time<BR> and tpa_unic_msc_sum.sv_id=-1;</DIV>
<DIV> foreach<BR> select ne_id,ne_type,first_result,g42,g66,g45,g43,g65,g411,g67<BR> into v_ne_id,v_ne_type,v_time,v42,v66,v45,v43,v65,v411,v67<BR> from chk_grade<BR> where first_result=s_time<BR> ------------------g42-------------------<BR> if v42 - 88 >= 0 then<BR> if v42 - 88 >= 5 then<BR> let f42 = 5;<BR> else<BR> let f42 = 3 + (v42 - 88)*0.4;<BR> end if;<BR> end if;<BR> if v42 - 88 < 0 then<BR> if 88 - v42 >= 10 then<BR> let f42 = 0;<BR> else<BR> let f42 = 3 + (v42 - 88)*0.3;<BR> end if;<BR> end if;<BR> update chk_grade set g42_fact = f42 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> -------------------------------------<BR> ------------------g66-------------------<BR> if v66 - 100 >= 0 then<BR> if v66 - 100 >= 30 then<BR> let f66 = 5;<BR> else<BR> let f66 = 3 + (v66 - 100)*0.4/6;<BR> end if;<BR> end if;<BR> if v66 - 100 < 0 then<BR> if 100 - v66 >= 60 then<BR> let f66 = 0;<BR> else<BR> let f66 = 3 + (v66 - 100)*0.3/6;<BR> end if;<BR> end if;<BR> update chk_grade set g66_fact = f66 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> -------------------------------------<BR> ------------------g45-------------------<BR> if v45 - 92 >= 0 then<BR> if v45 - 92 >= 4 then<BR> let f45 = 3;<BR> else<BR> let f45 = 1.8 + (v45 - 92)*0.3;<BR> end if;<BR> end if;<BR> if v45 - 92 < 0 then<BR> if 92 - v45 >= 6 then<BR> let f45 = 0;<BR> else<BR> let f45 = 1.8 + (v45 - 92)*0.3;<BR> end if;<BR> end if;<BR> update chk_grade set g45_fact = f45 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> --------------------------------------<BR> ------------------g43-------------------<BR> if v43 >= 95 then<BR> if v43 >= 99 then<BR> let f43 = 3;<BR> else<BR> let f43 = 1.8 + (v43 - 95)*0.3;<BR> end if;<BR> end if;<BR> if v43 < 95 then<BR> if v43 <= 91 then<BR> let f43 = 0;<BR> else<BR> let f43 = 3 + (v43 - 95)*0.45;<BR> end if;<BR> end if;<BR> update chk_grade set g43_fact = f43 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> -------------------------------------<BR> ------------------g65-------------------<BR> if v65 <= 1.1 then<BR> if v65 <= 0.7 then<BR> let f65 = 3;<BR> else<BR> let f65 = 1.8 + (1.1 - v65)*3;<BR> end if;<BR> end if;<BR> if v65 > 1.1 then<BR> if v65 >= 1.7 then<BR> let f65 = 0;<BR> else<BR> let f65 = 1.8 + (1.1 - v65)*3;<BR> end if;<BR> end if;<BR> update chk_grade set g65_fact = f65 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> -------------------------------------<BR> ------------------g411-------------------<BR> if v411 >= 88 then<BR> if v411 >= 94 then<BR> let f411 = 3;<BR> else<BR> let f411 = 1.8 + (v411 - 88)*0.2;<BR> end if;<BR> end if;<BR> if v411 < 88 then<BR> if v411 <= 82 then<BR> let f411 = 0;<BR> else<BR> let f411 = 1.8 + (v411 - 88)*0.3;<BR> end if;<BR> end if;<BR> update chk_grade set g411_fact = f411 where ne_id = v_ne_id and ne_type = v_ne_type and firs<BR>t_result = v_time;<BR> -------------------------------------<BR> ------------------g67-------------------<BR> if v67 <= 2 then<BR> if v67 <= 0.8 then<BR> let f67 = 3;<BR> else<BR> let f67 = 1.8 + (2 - v67)*1;<BR> end if;<BR> end if;<BR> if v67 > 2 then<BR> if v67 >= 3.8 then<BR> let f67 = 0;<BR> else<BR> let f67 = 1.8 + (2 - v67)*1;<BR> end if;<BR> end if;<BR> update chk_grade set g67_fact = f67 where ne_id = v_ne_id and ne_type = v_ne_type and first_<BR>result = v_time;<BR> -------------------------------------</DIV>
<DIV> end foreach; <BR> end procedure;</DIV></DIV>

ring04h 2006-3-14 12:59

create procedure "npmuser".super_busy_cell(s_time datetime year to second)
SET DEBUG FILE TO &#39;/tmp/superbusycell.log&#39;;
TRACE &#39;BEGIN 24h traff&#39;;
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;

ring04h 2006-3-14 12:59

虽然写的很简单,但是做完了才发现写一个存储过程是多么的英明,省了N多事。
另外在SPL的SQL语句中不能事实first的语法;
不能使用select a into v_a from table order by 1;
不在order by 之后into 到变量中

create procedure "npmuser".fact_busy_table(s_time datetime year to day)
      define a_traf float;
      define m_time  datetime year to second;
      
SET DEBUG FILE TO &#39;/tmp/factbusytable.log&#39;;
TRACE &#39;BEGIN 24h traff&#39;;
TRACE ON;
      delete from fact_msc where compress_date=s_time;
      delete from fact_bts where compress_date=s_time;
      delete from fact_gsma where compress_date=s_time;
      select  max(a_interface_traf) into a_traf from tpa_unic_msc_sum
      where compress_date=s_time
      and ne_type=10000
      and sum_level=0
      and sv_id=-1;
      
      select first_result into m_time from tpa_unic_msc_sum
      where compress_date=s_time
      and ne_type=10000
      and sum_level=0
      and sv_id=-1
      and a_interface_traf=a_traf;
      insert into fact_msc
      select *
      from tpa_unic_msc_sum
      where first_result=m_time
      and ne_type in (101,10003,10000);
      insert into fact_bts
      select *
      from tpa_unic_bts_sum
      where first_result=m_time
      and ne_type in (200,10003,10000);
      insert into fact_gsma
      select *
      from tpa_gsma_unic_sum
      where first_result=m_time
      and ne_type in (10003,10000);
end procedure;

页: [1]
© 1999-2008 EvilOctal Security Team