读书人

oracle找不到数据 有关问题的解决

发布时间: 2012-02-02 23:57:14 作者: rapoo

oracle找不到数据 问题的解决
select D into C from qyjbxx where A=B; 当在没有满足A=B时 oracle报错 (1403 未找到任何数据)
D 为 number类型
我现在想找到不数据能不能不让它报错,提示条消息就行了。我百度了下好像oracle中也有类似java的异常捕获,
select D into C from qyjbxx where A=B;
exception
when no_data_found then
Err.oi_errcode := -1;
Err.oc_errtext := 'XXXX';
return;
不能通过编译 好像 select语句下不能接exception
哪位高手有什么好的方法!谢谢了

[解决办法]

SQL code
beginselect D into C from qyjbxx where A=B;    exception    when no_data_found then    Err.oi_errcode := -1;  Err.oc_errtext := 'XXXX';  return;end;
[解决办法]
plsql的基本单元就是plsql程序块

begin
exception
end;
这就是一个块。

探讨

引用:
SQL code


begin

select D into C from qyjbxx where A=B;
exception
when no_data_found then
Err.oi_errcode := -1;
Err.oc_errtext := 'XXXX';
return;
end;

应该我原来的sel……

读书人网 >oracle

热点推荐