最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

Oracle触发器中selectinto报错no_data_found异常处理

来源:动视网 责编:小采 时间:2020-11-09 11:17:13
文档

Oracle触发器中selectinto报错no_data_found异常处理

Oracle触发器中selectinto报错no_data_found异常处理:Oracle触发器中select into 报错no_data_found异常处理 红色部分为对查询不到数据异常的处理 create or replace trigger TIG_MONITOR_ALARM after insert on t_monitor_real_minute for each rowdeclare
推荐度:
导读Oracle触发器中selectinto报错no_data_found异常处理:Oracle触发器中select into 报错no_data_found异常处理 红色部分为对查询不到数据异常的处理 create or replace trigger TIG_MONITOR_ALARM after insert on t_monitor_real_minute for each rowdeclare


Oracle触发器中select into 报错no_data_found异常处理

红色部分为对查询不到数据异常的处理

create or replace trigger TIG_MONITOR_ALARM

after insert on t_monitor_real_minute
for each row
declare
-- 标准值
standvalue number;
--报警实况表id
liveid number;
begin
--
--触发器功能:监测实况数据表,,对比监测数据是否超标,超标数据则记录入超标报警表中
--
standvalue:=-1;
liveid:=-1;
select nvl(t.bzz,-1) into standvalue from t_monitor_factor t where t.jcdbm=:new.STATION_ID and t.jcxmbm=:new.INFECTANT_ID;

--如果录入检测项目数据大于标准值,则入库报警信息表中
if standvalue>-1 then
if :new.M_VALUE>standvalue then
--将数据录入报警历史数据中
insert into t_alarm_history(id,jcdbm,jcxmbm,mvalue,mtime)
values(SEQ_ALARM_HISTORY.NEXTVAL,:new.STATION_ID,:new.INFECTANT_ID,:new.M_VALUE,:new.M_TIME);

--异常判断,如果查询不到数据
begin
select r.id into liveid from t_alarm_real r where r.jcdbm=:new.STATION_ID and r.jcxmbm=:new.INFECTANT_ID;
--查询不到数据
EXCEPTION
WHEN no_data_found THEN
--不存在则录入新的报警实况
insert into t_alarm_history(id,jcdbm,jcxmbm,mvalue,mtime)
values(SEQ_ALARM_REAL.NEXTVAL,:new.STATION_ID,:new.INFECTANT_ID,:new.M_VALUE,:new.M_TIME);
end;
--报警实况中是否已存在该监测点的该因子报警信息
if liveid>-1 then
update t_alarm_real r1 set r1.mvalue=:new.M_VALUE,r1.mtime=:new.M_TIME,r1.status=0 where r1.id=liveid;
else
--不存在则录入新的报警实况
insert into t_alarm_history(id,jcdbm,jcxmbm,mvalue,mtime)
values(SEQ_ALARM_REAL.NEXTVAL,:new.STATION_ID,:new.INFECTANT_ID,:new.M_VALUE,:new.M_TIME);
end if;
end if;
end if;

EXCEPTION
WHEN no_data_found THEN
null;

end TIG_MONITOR_ALARM;

文档

Oracle触发器中selectinto报错no_data_found异常处理

Oracle触发器中selectinto报错no_data_found异常处理:Oracle触发器中select into 报错no_data_found异常处理 红色部分为对查询不到数据异常的处理 create or replace trigger TIG_MONITOR_ALARM after insert on t_monitor_real_minute for each rowdeclare
推荐度:
标签: 处理 oracle found
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top