问题:
RA-06502: PL/SQL: 数字或值错误 : 字符串缓存区太小
ora-06512:在"xx.xxxxxxxx",line 316
ora-1403 :no data found
ora-06512:at line 1
原因分析:
根据RA-06502,判断定义的变量空间太小,结合ora-1403 :no data found,判断是因为变量赋值为空的时候产生的报错。
找到错误位置:
if count > 0 then
for cc in (select pk_id from ss.tb_sss)
loop
select pro_id
into v_pro_id
from ss.tb_ee t
where t.pk_id = cc.pk_id
begin
ss.pro_test_tmp(v_pro_id );
end;
end loop;
end if;
查出 :
select pk_id from ss.tb_sss 为210行数据
select pro_id
from ss.tb_ee t
where t.pk_id in (select pk_id from ss.tb_sss)
为200 行数据;
所以当用 条件 where t.pk_id = cc.pk_id 进行匹配时 必定有为空现象出现
select ... into... from ...
会报错。
这需要进行报错处理,同时为空时,需要跳出本次循环,不执行循环中的存储过程。
重点:
跳出本次循环: continue;
跳出循环: exit;
更正代码:
if count > 0 then
for cc in (select pk_id from ss.tb_sss)
loop
begin
select pro_id
into v_pro_id
from ss.tb_ee t
where t.pk_id = cc.pk_id
exception
when others then
continue;
ss.pro_test_tmp(v_pro_id );
end;
end loop;
end if;