oracle数据异常处理--抛出特定异常(转)
2006-11-02 11:51
423 查看
1. 在PL/SQL 块的定义部分定义异常情况:
<异常情况> EXCEPTION;
2. 将其定义好的异常情况,与标准的ORACLE错误联系起来,使用EXCEPTION_INIT语句:
PRAGMA EXCEPTION_INIT(<异常情况>, <错误代码>);
3. 在PL/SQL 块的异常情况处理部分对异常情况做出相应的处理。
Associating a PL/SQL Exception with a Number: Pragma EXCEPTION_INIT
To handle error conditions (typicallyORA-messages) that have no predefined name, you must use the
OTHERShandler or the pragma
EXCEPTION_INIT. A pragma is a compiler directive that is processed at compile time, not at run time.
In PL/SQL, the pragma
EXCEPTION_INITtells the compiler to associate an exception name with an Oracle error number. That lets you refer to any internal exception by name and to write a specific handler for it. When you see an error stack, or sequence of error messages, the one on top is the one that you can trap and handle.
You code the pragma
EXCEPTION_INITin the declarative part of a PL/SQL block, subprogram, or package using the syntax
PRAGMA EXCEPTION_INIT(exception_name, -Oracle_error_number);
where
exception_nameis the name of a previously declared exception and the number is a negative value corresponding to an
ORA-error number. The pragma must appear somewhere after the exception declaration in the same declarative section, as shown in the following example:
DECLARE deadlock_detected EXCEPTION; PRAGMA EXCEPTION_INIT(deadlock_detected, -60); BEGIN null; -- Some operation that causes an ORA-00060 error EXCEPTION WHEN deadlock_detected THEN null; -- handle the error END; /
相关文章推荐
- oracle 游标中抛出异常的处理方式
- 异常删除oracle数据文件的处理办法
- oracle数据异常处理
- oracle 异常处理、异常分类、异常的抛出、异常的传播
- oracle10g- oracle关于数据操作时异常的处理 编写自定义的异常
- 数据交换程序异常引发的艰难的ORACLE数据提纯作业
- PHP如何抛出异常处理错误
- direct=true 错误处理方法 (关于 Oracle 的数据导入导出及 Sql Loader (sqlldr) 的用法
- C++中异常处理的基本思想及throw语句抛出异常的使用
- 触发器|存储过程 抛出异常——>oracle
- Oracle基本操作十:异常处理
- oracle查询表中某一特定类型的数据特别慢,也没找到原因
- 对std::out_of_range抛出异常进行处理
- oracle存储过程中异常处理应注意的问题
- JAVA语言如何进行异常处理,关键字:throws,throw,try,catch,finally分别代表什么意义?在try块中可以抛出异常吗?
- JOptionpane.showinputdialog 数据异常 处理
- 误删除ORACLE数据文件后的处理方式
- 5、URL异常处理和HTTP状态码抛出异常
- 将Controller抛出的异常转到特定View
- 总结:整理 oracle异常错误处理