afunms

          My Software,My Dream—Forge a more perfect NMS product.

          oracle procedure

          好幾年沒寫過存諸過程了,都忘光了。今天由于需求,又寫了一個。

          create or replace procedure stat_app_traffic
          as
            queryhour varchar2(15);
            lasthour number;
          begin
            lasthour:= to_number(to_char(sysdate,'HH24')) - 1;
            if(lasthour=-1) then
               queryhour:= to_char(sysdate-1,'YYYY-MM-DD ') || '23';
            else      
               queryhour:= to_char(sysdate,'YYYY-MM-DD ') || lasthour;
            end if;
           
            insert into app_traffic(app,bytes,log_time)
            select app,round(sum(bytes)/1024/1024,2),max(log_time) from
            ((select b.app,a.src_port port,a.out_bytes bytes,a.log_time
            from raw_netflow a,app_config b
            where a.src_port=b.port and a.protocol=b.protocol_id
            and to_char(log_time,'YYYY-MM-DD HH24')=queryhour)
            union
            (select b.app,a.dst_port port,a.in_bytes bytes,a.log_time
            from raw_netflow a,app_config b
            where a.dst_port=b.port and a.protocol=b.protocol_id
            and to_char(log_time,'YYYY-MM-DD HH24')=queryhour)) group by app; 
           
            commit;

          end stat_app_traffic;

          posted on 2008-02-19 17:29 afunms 閱讀(314) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 库车县| 漳浦县| 团风县| 吉隆县| 宣威市| 凤山市| 宿迁市| 应用必备| 射阳县| 固镇县| 亳州市| 兖州市| 呈贡县| 荃湾区| 谢通门县| 琼海市| 南平市| 达拉特旗| 永仁县| 南昌县| 专栏| 偃师市| 北京市| 北碚区| 内丘县| 金沙县| 安新县| 威远县| 庆元县| 三亚市| 西藏| 宜黄县| 梧州市| 谢通门县| 恩平市| 肃宁县| 嘉定区| 龙南县| 济源市| 潢川县| 肇庆市|