zoukankan      html  css  js  c++  java
  • TRIGGERS_监测系统_多表视图触发器—向原始数据报表中插入数据

    Create Or Replace Trigger trg_view_report
      Instead Of Insert or update or delete on view_for_report
      for each row
    Declare

    begin
      If Inserting Then
     
       
        if :new.temperature1 <= 250 then
            
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             1,
             '传感器一',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature1,
             :new.humidity1);
          
            
        end if;
        if :new.temperature2 <= 250 then
          
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             2,
             '传感器二',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature2,
             :new.humidity2);
        end if;
        if :new.temperature3 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             3,
             '传感器三',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature3,
             :new.humidity3);
        end if;
        if :new.temperature4 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             4,
             '传感器四',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature4,
             :new.humidity4);
        end if;
        if :new.temperature5 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             5,
             '传感器五',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature5,
             :new.humidity5);
        end if;
        if :new.temperature6 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             6,
             '传感器六',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature6,
             :new.humidity6);
        end if;
        if :new.temperature7 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             7,
             '传感器七',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature7,
             :new.humidity7);
        end if;
        if :new.temperature8 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             8,
             '传感器八',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature8,
             :new.humidity8);
        end if;
        if :new.temperature9 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             9,
             '传感器九',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature9,
             :new.humidity9);
        end if;
        if :new.temperature10 <= 250 then
          insert into originaldata_report
            (id,
             wid,
             wname,
             jurisdiction,
             jurisdiction_name,
             year,
             month,
             day,
             temperature,
             humidity)
          values
            (originaldata_report_id.nextval,
             :new.wid,
             :new.wname,
             10,
             '传感器十',
             :new.year,
             :new.month,
             :new.day,
             :new.temperature10,
             :new.humidity10);
        end if;
      elsif Deleting then
        Delete from originaldata_report t where t.wid = :Old.wid;
      End if;
    end ;

  • 相关阅读:
    matlab中figure 创建图窗窗口
    matlab中imread 从图形文件读取图像
    matlab中imfinfo 有关图形文件的信息
    matlab中bitshift 将位移动指定位数
    matlab中reshape 重构数组
    matlab中find 查找非零元素的索引和值
    比特数
    matlab中fseek 移至文件中的指定位置
    poj 1039 Pipe(几何基础)
    poj 1556 The Doors(线段相交,最短路)
  • 原文地址:https://www.cnblogs.com/hy928302776/p/3233262.html
Copyright © 2011-2022 走看看