zoukankan      html  css  js  c++  java
  • PROCEDURE_监测系统_原始数据报表数据生成存储过程—求每天平均值插入多表视图

    create or replace procedure proc_generate_report(in_date in varchar2) is
      v_retCode varchar2(20);
      v_retMsg  varchar2(500);
    begin
      v_retCode:= '';
      v_retMsg:= '';
      insert into view_for_report
      select t.id,
             max(w.wid) wid,
             max(w.wname) wname,
             substr(max(t.time), 1, 4) year,
             substr(max(t.time), 6, 2) month,
             substr(max(t.time), 9, 2) day,
             round(avg(temperature1), 2) temperature1,
             round(avg(humidity1), 2) humidity1,
             round(avg(temperature2), 2) temperature2,
             round(avg(humidity2), 2) humidity2,
             round(avg(temperature3), 2) temperature3,
             round(avg(humidity3), 2) humidity3,
             round(avg(temperature4), 2) temperature4,
             round(avg(humidity4), 2) humidity4,
             round(avg(temperature5), 2) temperature5,
             round(avg(humidity5), 2) humidity5,
             round(avg(temperature6), 2) temperature6,
             round(avg(humidity6), 2) humidity6,
             round(avg(temperature7), 2) temperature7,
             round(avg(humidity7), 2) humidity7,
             round(avg(temperature8), 2) temperature8,
             round(avg(humidity8), 2) humidity8,
             round(avg(temperature9), 2) temperature9,
             round(avg(humidity9), 2) humidity9,
             round(avg(temperature10), 2) temperature10,
             round(avg(humidity10), 2) humidity10
        from originaldata t, warehouse_new w
       where t.id = w.client_id
         and t.time <= in_date
       group by t.id;
      commit;
    exception
      when others then
        v_retCode := sqlcode;
        v_retMsg  := sqlerrm || sysdate;
        insert into operationlog
          (id, time, behavior, state, reason)
        values
          (operationlog_id_seq.nextval,
           to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss'),
           '生成报表数据',
           0,
           v_retMsg);
        commit;
    end proc_generate_report;

  • 相关阅读:
    The best programmers are the quickest to Google
    NetBeans 时事通讯(刊号 # 117 Sep 16, 2010)
    Apache HttpClient 4.0.3 GA 发布
    warning LNK4070的解决办法
    看泡沫
    早秋精神
    NetBeans 时事通讯(刊号 # 117 Sep 16, 2010)
    Maven 3.0 RC1 发布
    关于类的数据成员的访问权限设计的一些思考
    看泡沫
  • 原文地址:https://www.cnblogs.com/hy928302776/p/3233247.html
Copyright © 2011-2022 走看看