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 ;

TRIGGERS_监测系统_多表视图触发器—向原始数据报表中插入数据的更多相关文章

  1. TRIGGERS_监测系统_原始数据表触发器—调用告警信息存储过程

    //每次向originaldata表中插入数据就会触发该触发器 create or replace trigger originaldata_to_alarm  after insert on ori ...

  2. 触发器修改后保存之前的数据 表中插入数据时ID自动增长

    create or replace trigger t before update on test5 for each rowbegin insert into test55 values (:old ...

  3. 第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据

    第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据 ADO.NET 为什么要学习? 我们要搭建一个平台(Web/Winform ...

  4. Hive通过查询语句向表中插入数据注意事项

    最近在学习使用Hive(版本0.13.1)的过程中,发现了一些坑,它们或许是Hive提倡的比关系数据库更加自由的体现(同时引来一些问题),或许是一些bug.总而言之,这些都需要使用Hive的开发人员额 ...

  5. EF Core中,通过实体类向SQL Server数据库表中插入数据后,实体对象是如何得到数据库表中的默认值的

    我们使用EF Core的实体类向SQL Server数据库表中插入数据后,如果数据库表中有自增列或默认值列,那么EF Core的实体对象也会返回插入到数据库表中的默认值. 下面我们通过例子来展示,EF ...

  6. (笔记)Mysql命令insert into:向表中插入数据(记录)

    insert into命令用于向表中插入数据. insert into命令格式:insert into <表名> [(<字段名1>[,..<字段名n > ])] v ...

  7. Mysql命令insert into:向表中插入数据(记录)

    insert into命令用于向表中插入数据. insert into命令格式:insert into <表名> [(<字段名1>[,..<字段名n > ])] v ...

  8. 初学者使用MySQL_Workbench 6.0CE创建数据库和表,以及在表中插入数据。

    标签: mysqlworkbench数据库 2013-10-09 20:17 19225人阅读 评论(14) 收藏 举报  分类: mysql(1)  版权声明:本文为博主原创文章,未经博主允许不得转 ...

  9. Hive通过查询语句向表中插入数据过程中发现的坑

    前言 近期在学习使用Hive(版本号0.13.1)的过程中,发现了一些坑,它们也许是Hive提倡的比关系数据库更加自由的体现(同一时候引来一些问题).也许是一些bug.总而言之,这些都须要使用Hive ...

随机推荐

  1. file_get_contents 获取不了网页内容

    服务器在做验签的过程中,经常需要向渠道服务器获取某个用户的信息.一般有两种方法,curl和file_get_contents. 一般情况下,像这样用,不会有问题. public function Oa ...

  2. 给EcStore商城会员添加推广返利功能

    EcStore商城后台应用中心安装“网站推广”应用,会员成为推广员有二种途径:一是后台/推广设置/推广员审核/推广注册模式设为:需注册后审核成为推广员 此模式下前台会员在使用推广前,需要在会员中心申请 ...

  3. [linux]linux下开启wifi热点

    网上说用 ap-hotspot可以,但是我测试的时候总是在start的时候卡主,试了以前的版本也是,最后找到了下面的方法. 第一步:安装 plasma-nm 可以使用下面的命令 sudo apt-ge ...

  4. Django RESTful API 设计指南

    网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板.桌面电脑.其他专用设备......). 因此,必须有一种统一的机制,方便不同的前端设备与后端进行通信.这导致AP ...

  5. Linux(Centos)下安装MySQL

    转载:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 一.mysql简介 说到数据库,我们大多想到的是关 ...

  6. 设置WebSphere字符集参数

    设置WebSphere字符集参数 1. 登陆was控制台 2. 依次点击服务器→服务器类型→应用服务器,显示应用程序服务器页面: 3. 选择并点击需要设置字符集的服务器,比如说本例中的server1  ...

  7. rlwrap 的安装使用

    rlwrap 的安装使用 在Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重 ...

  8. mysql----用户root被删除或忘记root密码的解决方案

    修改文件my.cnf,可用VIM打开,如:sudo vim /etc/my.cnf 在[mysqld]下加上一行: skip-grant-tables 保存文件,然后重启mysqld程序:sudo s ...

  9. MSDN中HttpWebRequest/HttpWebResponse用法

    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://home.cnblogs.com/u/weiweiboqi/ ...

  10. python学习之路-1 python基础操作

    本篇所涉及的内容 变量 常量 字符编码 用户交互input 格式化字符串 python的缩进规则 注释 初始模块 条件判断 循环 变量 变量的概念基本上和初中代数的方程变量是一致的,只是在计算机程序中 ...