使用例外處理
--example
begin
select fld into v_tmp from table;
exception
when no_data_found then
fld := '默認值';
END;
--example
begin
select fld into v_tmp from table;
exception
when no_data_found then
fld := '默認值';
END;
解决方案 »
- oracle数据库创建表主外键语法
- oracle 10g 连接 Sql 2005 错误提示NCR-000002 官方解释 调用函数错误
- sqlplus查询数据
- this question is very lower, I need you help! Thanks!!数据库启动问题
- 血本提问100分!!!!!
- 十万火急:oracle forms 安装以后如何配置?
- 用vc读取字段的值时,遇到空值时怎么办?
- 如何在一个存储过程中调用另一个存储过程?
- linux 7.2下Oracle8i的Pro*c编译环境
- 关于两个数据库之间的性能对比
- ORACLE的数据类型都有那些啊?有人能详细列出来并说明一下吗?谢谢
- 急!!!求一sql语句!请大侠帮忙!
nvl只对null值处理,而你的select fld into v_tmp from table是返回空记录。
if isnull(ll_count) then ll_count = 0
if ll_count > 0 then
select fld into v_tmp from table ;
else
// do ...
end
用例外处理的方法好一点。
我觉得最好还是Oracle自己能提供赋默认值的方法,不过看来现在还没有。
结贴了。