当前位置: 代码迷 >> Oracle管理 >> 求存储过程异常!新手指导
  详细解决方案

求存储过程异常!新手指导

热度:107   发布时间:2016-04-24 04:16:16.0
求存储过程错误!新手指导

fetch mycur into v_code;
exit when  mycur%NOTFOUND;
if()  then
在循环中 
  为什么语句会报01423错误
  Select N_S into N_S_DATA from ben_sve_merge where CELLCODE = v_code;   --v_code 定义变量
end if;



PS: 循环插入数据库  单写 存储过程可以执行 放到package 就无法执行了?

------解决方案--------------------
Select N_S into N_S_DATA from ben_sve_merge where CELLCODE = v_code;   
这里是不是返回多行了
查一下cellcode是否有重复
select cellcode from ben_sve_merge group by cellcode having count(1)>1;
------解决方案--------------------
Select N_S into N_S_DATA from ben_sve_merge where CELLCODE = v_code;

你这个查询是不是有多个纪录值。
------解决方案--------------------
这个错误是检查实际读取的多余行时会报错!楼主仔细看下表。
------解决方案--------------------
引用:

fetch mycur into v_code;
exit when  mycur%NOTFOUND;
if()  then
在循环中 
  为什么语句会报01423错误
  Select N_S into N_S_DATA from ben_sve_merge where CELLCODE = v_code;   --v_code 定义变量
end if;



PS: 循环插入数据库  单写 存储过程可以执行 放到package 就无法执行了?

很有可能是以下语句返回了多条记录导致报错:

Select N_S into N_S_DATA from ben_sve_merge where CELLCODE = v_code; 
------解决方案--------------------
具体的过程,和放入包后的执行代码?
------解决方案--------------------
是有重复的,楼主表里面查查看呗!
------解决方案--------------------
cursor cs is  select * from table后面加上分号

包体定义后面少个end;
------解决方案--------------------
where条件过滤后多于一条数据
------解决方案--------------------
直接
insert into table (xxx,xxx,xxx) select xxx,xxx,xxx from table不行么,为什么要用游标?
  相关解决方案