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)  編輯  收藏


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


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 扎兰屯市| 延安市| 青铜峡市| 广南县| 广汉市| 德兴市| 天镇县| 永兴县| 石景山区| 如皋市| 潜江市| 陆良县| 板桥市| 仪征市| 海门市| 东丰县| 怀安县| 集贤县| 扎赉特旗| 哈密市| 大足县| 平阴县| 静安区| 伊金霍洛旗| 宣威市| 长泰县| 富平县| 黑河市| 文山县| 扎兰屯市| 临泽县| 克什克腾旗| 成都市| 晋州市| 瑞昌市| 汝城县| 合作市| 巨鹿县| 左权县| 普兰店市| 东乡县|