oracle存储过程出现ORA-01403: 未找到数据 问题解决方法

这段时间在做一个业务,需要用到存储过程处理业务逻辑,但是出现一个ORA-01403: 未找到数据 问题,

那么这个应该如何解决这个问题

declare mixType integer;
begin
   --原先获取方式--
   select NVL(MID,0) into mixType from DXC_MIXTYPE where Name='常温111' and RowNum=1;
end;

如果根据条件找不到,是无法赋值到mixType中的

解决方法我采用这种处理方式

declare mixType integer;
begin
  --默认如果找不到,默认给0值---
  select count(*) into mixType from DXC_MIXTYPE where Name='常温111' and RowNum=1;
  if mixType>0 then
    select NVL(MID,0) into mixType from DXC_MIXTYPE where Name='常温111' and RowNum=1;
  end if; 
end;

Ps:

参考网址来源: https://blog.csdn.net/u010999809/article/details/80663895

猜你喜欢

转载自www.cnblogs.com/xielong/p/10716078.html
今日推荐