- 浏览: 1150618 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
Handling PL/SQL Errors:
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm
Retrieving the Error Code and Error Message: SQLCODE and SQLERRM:
In an exception handler, you can use the built-in functions SQLCODE and SQLERRM to find out which error occurred and to get the associated error message. For internal exceptions, SQLCODE returns the number of the Oracle error. The number that SQLCODE returns is negative unless the Oracle error is no data found, in which case SQLCODE returns +100. SQLERRM returns the corresponding error message. The message begins with the Oracle error code.
For user-defined exceptions, SQLCODE returns +1 and SQLERRM returns the message: User-Defined Exception.
unless you used the pragma EXCEPTION_INIT to associate the exception name with an Oracle error number, in which case SQLCODE returns that error number and SQLERRM returns the corresponding error message. The maximum length of an Oracle error message is 512 characters including the error code, nested messages, and message inserts such as table and column names.
If no exception has been raised, SQLCODE returns zero and SQLERRM returns the message: ORA-0000: normal, successful completion.
You can pass an error number to SQLERRM, in which case SQLERRM returns the message associated with that error number. Make sure you pass negative error numbers to SQLERRM. In the following example, you pass positive numbers and so get unwanted results:
Passing a positive number to SQLERRM always returns the message user-defined exception unless you pass +100, in which case SQLERRM returns the message no data found. Passing a zero to SQLERRM always returns the message normal, successful completion.
You cannot use SQLCODE or SQLERRM directly in a SQL statement. Instead, you must assign their values to local variables, then use the variables in the SQL statement, as shown in the following example:
The string function SUBSTR ensures that a VALUE_ERROR exception (for truncation) is not raised when you assign the value of SQLERRM to err_msg. The functions SQLCODE and SQLERRM are especially useful in the OTHERS exception handler because they tell you which internal exception was raised.
Note: When using pragma RESTRICT_REFERENCES to assert the purity of a stored function, you cannot specify the constraints WNPS and RNPS if the function calls SQLCODE or SQLERRM.
Oracle Exception Handling:
http://psoug.org/reference/exception_handling.html
Oracle/PLSQL Topics: Exception Handling:
http://www.techonthenet.com/oracle/exceptions/
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm
引用
Retrieving the Error Code and Error Message: SQLCODE and SQLERRM:
In an exception handler, you can use the built-in functions SQLCODE and SQLERRM to find out which error occurred and to get the associated error message. For internal exceptions, SQLCODE returns the number of the Oracle error. The number that SQLCODE returns is negative unless the Oracle error is no data found, in which case SQLCODE returns +100. SQLERRM returns the corresponding error message. The message begins with the Oracle error code.
For user-defined exceptions, SQLCODE returns +1 and SQLERRM returns the message: User-Defined Exception.
unless you used the pragma EXCEPTION_INIT to associate the exception name with an Oracle error number, in which case SQLCODE returns that error number and SQLERRM returns the corresponding error message. The maximum length of an Oracle error message is 512 characters including the error code, nested messages, and message inserts such as table and column names.
If no exception has been raised, SQLCODE returns zero and SQLERRM returns the message: ORA-0000: normal, successful completion.
You can pass an error number to SQLERRM, in which case SQLERRM returns the message associated with that error number. Make sure you pass negative error numbers to SQLERRM. In the following example, you pass positive numbers and so get unwanted results:
DECLARE err_msg VARCHAR2(100); BEGIN /* Get all Oracle error messages. */ FOR err_num IN 1..9999 LOOP err_msg := SQLERRM(err_num); -- wrong; should be -err_num INSERT INTO errors VALUES (err_msg); END LOOP; END;
Passing a positive number to SQLERRM always returns the message user-defined exception unless you pass +100, in which case SQLERRM returns the message no data found. Passing a zero to SQLERRM always returns the message normal, successful completion.
You cannot use SQLCODE or SQLERRM directly in a SQL statement. Instead, you must assign their values to local variables, then use the variables in the SQL statement, as shown in the following example:
DECLARE err_num NUMBER; err_msg VARCHAR2(100); BEGIN ... EXCEPTION WHEN OTHERS THEN err_num := SQLCODE; err_msg := SUBSTR(SQLERRM, 1, 100); INSERT INTO errors VALUES (err_num, err_msg); END;
The string function SUBSTR ensures that a VALUE_ERROR exception (for truncation) is not raised when you assign the value of SQLERRM to err_msg. The functions SQLCODE and SQLERRM are especially useful in the OTHERS exception handler because they tell you which internal exception was raised.
Note: When using pragma RESTRICT_REFERENCES to assert the purity of a stored function, you cannot specify the constraints WNPS and RNPS if the function calls SQLCODE or SQLERRM.
Oracle Exception Handling:
http://psoug.org/reference/exception_handling.html
Oracle/PLSQL Topics: Exception Handling:
http://www.techonthenet.com/oracle/exceptions/
发表评论
-
Oracle: minus | in | exists
2012-09-05 13:49 1485解释及例子: MINUS Query: http://www. ... -
一个奇怪的Oracle sql问题
2011-01-13 16:13 1365select A.M,B.N from Table1 A ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST;PARTITION BY
2010-12-13 17:02 1319Oracle/PLSQL: Rank Function: ht ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST
2010-12-13 17:02 1268Oracle/PLSQL: Rank Function: ht ... -
Oracle:Collections Records Type %TYPE %ROWTYPE
2010-11-09 22:27 1273PL/SQL Collections and Records: ... -
Oracle Cursor 游标
2010-11-09 20:44 3050Oracle中Cursor介绍: http://www.ite ... -
Oracle 锁机制
2010-09-19 20:12 3725Oracle多粒度封锁机制研究: http://www.itp ... -
Oracle Data Dictionary 数据字典
2010-09-19 16:44 1545Oracle数据字典查阅: http://download.o ... -
Oracle Sign Function
2010-09-17 14:52 1466Oracle/PLSQL: Sign Function: ht ... -
Oracle Built-In Functions: Next_Day and Last_Day
2010-09-16 17:09 1542next_day(date,char): 它用来返回从第一个 ... -
Oracle Procedure 存储过程
2010-09-16 08:36 1365Oracle/PLSQL: Creating Procedur ... -
Oracle 性能工具 : Explain plan、Autotrace、Tkprof
2010-09-14 18:07 2232Oracle: 三个内置的性能工具包 Explain plan ... -
关于Oracle数据和对象的导入导出 [转]
2010-09-14 10:25 1273关于Oracle数据和对象的导入导出 [转]: http:// ... -
Oracle jobs(DBMS_JOB and DBMS_SCHEDULER)
2010-07-21 14:14 7828写PL/SQL procedure的时候,一定要写的够健壮、够 ... -
Oracle 各种注释
2010-07-20 14:19 3653为SQL语句添加注释: http://do ... -
Oracle 监听 本地Net服务名 配置
2010-07-20 10:32 1326Oracle数据库配置: http://shupili1410 ... -
[Oracle]Difference between a database and an instance(数据库 实例 区别)
2010-07-20 09:31 1502Difference between a database a ... -
Oracle Bulk Collect
2010-07-16 10:03 1375On BULK COLLECT: http://www.ora ... -
Oracle/PLSQL: FOR Loop 循环语句
2010-07-15 16:43 9355Oracle/PLSQL: FOR Loop: http:// ... -
Oracle Trigger 触发器
2010-06-09 16:37 1824备忘速查: oracle的update insert dele ...
相关推荐
Oracle 存储过程异常处理 Oracle 存储过程异常处理是指在 Oracle 数据库中使用存储过程时出现的异常情况的处理方法。异常处理是指在程序执行过程中出现错误或异常时,采取相应的处理措施,以确保程序的可靠性和...
3. **处理异常**:在程序的 `EXCEPTION` 块中编写异常处理代码。例如: ```plsql EXCEPTION WHEN first_exception THEN -- code to handle first exception WHEN second_exception THEN -- code to handle second...
### ORACLE 异常错误处理详解 #### 一、异常处理概述 在ORACLE数据库的开发过程中,无论是多么复杂的业务逻辑还是简单的数据操作,都不可避免地会遇到各种异常情况。有效的异常处理机制不仅可以帮助开发者更好地...
8. **异常处理**:OCI提供了错误处理机制,oci_error()获取错误信息,oci_handle_free()释放资源。使用oci_exception_handler()设置异常处理器。 9. **性能优化**:通过预编译(Precompilation)、绑定变量、批量...
- 注意点: Oracle使用 `EXCEPTION` 块来捕获异常,而DB2使用 `ON SQLERROR DO` 来处理异常。 #### 6. Package初始化 - **Oracle** 支持使用 `PACKAGE` 组织多个存储过程、函数等对象。 - Oracle示例: ```sql ...
-- Handle the exception END; ``` - **内置异常**:PL/SQL还提供了一些内置的异常,如`NO_DATA_FOUND`、`TOO_MANY_ROWS`等。 #### 六、总结 通过以上内容的学习,我们可以了解到PL/SQL是一种强大的数据库编程...
// Handle exception here } } if (conn != null) { try { conn.close(); } catch (SQLException e) { // Handle exception here } } } } } ``` 这段代码首先加载Oracle JDBC驱动,然后建立数据库连接,...
// TODO: handle exception } } // 创建数据库连接方法 public Connection create() { try { /* 使用Class.forName()方法自动创建这个驱动程序的实例且自动调用DriverManager来注册它 */ ...
Oracle提供了异常处理机制,通过`BEGIN...EXCEPTION...END`块来捕获和处理错误。例如: ```sql BEGIN -- SQL statements EXCEPTION WHEN OTHERS THEN -- Handle error END; / ``` **存储过程的维护** 1. **查看...
// Handle exception if necessary } } } ``` ##### 3.4 数据库更新操作 `public int Update(String SQL)`方法实现了对数据库执行更新操作的功能,如插入、删除或修改数据。该方法首先从连接池中获取连接,然后...
在Oracle 9i中使用PL/SQL进行文件读写,需要熟练掌握UTL_FILE包的使用方法,包括如何正确设置参数、处理异常以及编写有效的存储过程。这不仅可以提高数据处理的灵活性,还能增强应用程序的功能性和健壮性。
Locate and repair errors and employ exception handlers Execute black box, white box, and integration tests Configure and manage stored packages and libraries Handle security with authentication and ...
6. **HANDLE EXCEPTION(异常处理)** PL/SQL提供了一种机制来捕获和处理运行时发生的错误。通过EXCEPTION关键字,可以在程序中定义异常处理块,确保即使在出现错误时,程序也能优雅地结束或执行恢复操作。 7. **...
结合`cx_Oracle`和`smtp`,我们可以创建一个简单的应用程序,用于接收用户提交的数据,将其存储到Oracle数据库,并通过电子邮件将处理结果发送给用户。例如,用户通过表单提交请假申请,程序可以将申请信息存入...
当数据库操作失败时,可以通过捕获`OracleException`来处理错误。 8. **关闭和清理**:在完成所有数据库操作后,应关闭游标、断开连接,并释放分配的资源,以防止内存泄漏。 这个“demo.cpp”代码是初学者学习OCCI...
-- 处理异常 handle_error; END procedure_name; / ``` 这里的`procedure_name`是存储过程的名称,`parameter1, parameter2, ...`是输入、输出或输入/输出参数,`AS`关键字后是过程体,包括局部变量声明和执行的...
异常可以通过预定义的异常(如NO_DATA_FOUND、TOO_MANY_ROWS)或自定义异常来处理。示例如下: ```sql BEGIN -- some code that may raise an exception EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_...
通过BEGIN...EXCEPTION块可以捕获并处理异常。例如: ```sql BEGIN UPDATE employees SET salary = salary * 1.1; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM); END; ``` 7. UTL_...
3. **异常处理部分** (EXCEPTION):这部分用于捕获和处理执行过程中可能出现的错误或异常。这部分也不是必需的,但在复杂的应用程序中非常有用。 ### 变量声明与类型 #### 变量声明语法 ```sql var_name [CONSTANT...