ORACLE 异常处理
2014-05-01 02:29
453 查看
一、
开发PL/SQL程序时,需要考虑到程序运行时可能出现的各种异常,当异常出现时,或是中断程序运行,或是使程序从错误中恢复,从而继续运行。
常用的异常类型有:
no_data_found:没有发现数据
too_many_rows:select into 语句查询结果有多个数据行
others:可以捕捉所有异常,一般作为异常处理部分的最后一个异常处理器
二、例子
..
开发PL/SQL程序时,需要考虑到程序运行时可能出现的各种异常,当异常出现时,或是中断程序运行,或是使程序从错误中恢复,从而继续运行。
常用的异常类型有:
no_data_found:没有发现数据
too_many_rows:select into 语句查询结果有多个数据行
others:可以捕捉所有异常,一般作为异常处理部分的最后一个异常处理器
二、例子
-- v_code : 000 ,表示执行成功,其它表示执行失败 create or replace procedure detector_plsql_exception( v_deptno varchar2, v_dname out varchar2, v_code out varchar2, v_msg out varchar2 ) as begin select d.dname into v_dname from dept d where d.deptno = v_deptno; v_code := '000'; exception when no_data_found then v_code := '001'; v_msg := '找不到deptno为'||v_deptno||'的记录'; when too_many_rows then v_code := '002'; v_msg := 'deptno为'||v_deptno||'的记录多于一条'; when others then v_code := '999'; v_msg := '其它异常,'||sqlcode||','||sqlerrm; --sqlcode:当前错误代码 --sqlerrm:当前错误消息文件 end detector_plsql_exception;
..
相关文章推荐
- 验证TAR Oracle部署
- tar方式安装oracle11g
- oracle 数据库隔离级别学习
- Oracle 忘记用户名密码的处理方式
- Oracle数据库LOGGING&NOLOGGING模式概述
- 在SQL Server 2012中实现CDC for Oracle
- 在SQL Server 2012中实现CDC for Oracle
- 基于Struts2 Spring ibatis Oracle10g架构 多数据源动态切换实例
- ORACLE触发器调试
- oracle触发器与:new,:old的使用
- oracle数据库备份
- oracle与java的数据类型映射
- [ORACLE 性能优化] AWR中CPUS, CORES, SOCKETS
- 简介使用ASP.NET访问Oracle数据库的方法
- EXP-00056: ORACLE error 6550 encountered报错;
- EXP-00056: ORACLE error 6550 encountered报错;
- Oracle EBS WebADI的配置(IE+Excel)
- ORACLE【3】:分区表以及分区索引
- Oracle 11g下加密表空间的使用
- Oracle按时间段分组统计