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 ;
TRIGGERS_监测系统_多表视图触发器—向原始数据报表中插入数据的更多相关文章
- TRIGGERS_监测系统_原始数据表触发器—调用告警信息存储过程
//每次向originaldata表中插入数据就会触发该触发器 create or replace trigger originaldata_to_alarm after insert on ori ...
- 触发器修改后保存之前的数据 表中插入数据时ID自动增长
create or replace trigger t before update on test5 for each rowbegin insert into test55 values (:old ...
- 第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据
第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据 ADO.NET 为什么要学习? 我们要搭建一个平台(Web/Winform ...
- Hive通过查询语句向表中插入数据注意事项
最近在学习使用Hive(版本0.13.1)的过程中,发现了一些坑,它们或许是Hive提倡的比关系数据库更加自由的体现(同时引来一些问题),或许是一些bug.总而言之,这些都需要使用Hive的开发人员额 ...
- EF Core中,通过实体类向SQL Server数据库表中插入数据后,实体对象是如何得到数据库表中的默认值的
我们使用EF Core的实体类向SQL Server数据库表中插入数据后,如果数据库表中有自增列或默认值列,那么EF Core的实体对象也会返回插入到数据库表中的默认值. 下面我们通过例子来展示,EF ...
- (笔记)Mysql命令insert into:向表中插入数据(记录)
insert into命令用于向表中插入数据. insert into命令格式:insert into <表名> [(<字段名1>[,..<字段名n > ])] v ...
- Mysql命令insert into:向表中插入数据(记录)
insert into命令用于向表中插入数据. insert into命令格式:insert into <表名> [(<字段名1>[,..<字段名n > ])] v ...
- 初学者使用MySQL_Workbench 6.0CE创建数据库和表,以及在表中插入数据。
标签: mysqlworkbench数据库 2013-10-09 20:17 19225人阅读 评论(14) 收藏 举报 分类: mysql(1) 版权声明:本文为博主原创文章,未经博主允许不得转 ...
- Hive通过查询语句向表中插入数据过程中发现的坑
前言 近期在学习使用Hive(版本号0.13.1)的过程中,发现了一些坑,它们也许是Hive提倡的比关系数据库更加自由的体现(同一时候引来一些问题).也许是一些bug.总而言之,这些都须要使用Hive ...
随机推荐
- 关于Repeater中绑定的控件不触发ItemCommand事件
今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...
- fiddler2使用文档
http://www.trinea.cn/android/android-network-sniffer/
- 【劳动节江南白衣Calvin 】我的后端开发书架2015
自从技术书的书架设定为”床底下“之后,又多了很多买书的空间.中国什么都贵,就是书便宜. 不定期更新,在碎片化的阅读下难免错评. 书架主要针对Java后端开发,书单更偏爱那些能用简短流畅的话,把少壮不努 ...
- LUA 捕获模式 URL编码的例子解析
function escape(s) s=string.gsub(s,"([&=+%c])",function(c) return string.format(" ...
- python 学习(三)
按照上次python 学习(二)的思路,第一步要实现从一个网站的页面上自动获取指定列表中的信息.折腾数日,得到一段可以正常运行的代码,如下: #web2.py import re import url ...
- 安装完Apache和PHP之后访问PHP文件页面提示下载而没有解析 解决办法
装好LAMP环境后,还要做下整合Apache与PHP相关配置,在apache配置文件里找到:AddType application/x-gzip .gz .tgz在该行下面添加AddType appl ...
- Java抽象类深入理解-----模板方法设计模式(Templete Method)
模板方法设计模式(Templete Method) 定义一个操作中的算法骨架,而将一些可变部分的实现延迟到子类中. 模板方法设计模式使得子类可以不改变一个算法的结构即可重新定义该算法某些特定的步骤. ...
- JVM中可生成的最大Thread数量
最近想测试下Openfire下的最大并发数,需要开大量线程来模拟客户端.对于一个JVM实例到底能开多少个线程一直心存疑惑,所以打算实际测试下,简单google了把,找到影响线程数量的因素有下面几个: ...
- 清除IE输入框眼睛和叉叉
/* 清除IE输入框眼睛和叉叉 */::-ms-clear { display: none; } ::-ms-reveal { display: none; }
- HDU1841——KMP算法
这个题..需要对KMP的模板理解的比较透彻,以前我也只是会套模板..后来才知道..之会套模板是不行的..如果不能把握模板的每一个细节`,至少能搞清楚模板的每一个模块大体是什么意思.. 题意是给出两个串 ...