The SAVE EXCEPTIONS clause will record any exception during the bulk operation, and continue process
来源:互联网 发布:知乎专栏怎么写 编辑:程序博客网 时间:2024/06/07 13:13
The SAVE EXCEPTIONS clause will record any exception during the bulk operation, and continue processing.
http://www.java2s.com/Code/Oracle/PL-SQL/TheSAVEEXCEPTIONSclausewillrecordanyexceptionduringthebulkoperationandcontinueprocessing.htm
http://docs.oracle.com/cd/E21901_01/doc/timesten.1122/e21639/sqlexamples.htm#TTPLS364
http://psoug.org/reference/array_processing.html
SQL>
SQL> CREATE TABLE MyTable (
2 num_col NUMBER,
3 char_col VARCHAR2(60)
4 );
Table created.
SQL>
SQL>
SQL> DECLARE
2 TYPE t_Strings IS TABLE OF MyTable.char_col%TYPE
3 INDEX BY BINARY_INTEGER;
4 TYPE t_Numbers IS TABLE OF MyTable.num_col%TYPE
5 INDEX BY BINARY_INTEGER;
6 v_Strings t_Strings;
7 v_Numbers t_Numbers;
8 v_NumErrors NUMBER;
9 BEGIN
10 DELETE FROM MyTable;
11 FOR v_Count IN 1..10 LOOP
12 v_Strings(v_Count) := '123456789012345678901234567890';
13 v_Numbers(v_Count) := v_Count;
14 END LOOP;
15
16 FORALL v_Count IN 1..10
17 INSERT INTO MyTable (num_col, char_col)
18 VALUES (v_Numbers(v_Count), v_Strings(v_Count));
19
20 v_Strings(6) := v_Strings(6) || 'a';
21
22 FORALL v_Count IN 1..10 SAVE EXCEPTIONS
23 UPDATE MyTable
24 SET char_col = char_col || v_Strings(v_Count)
25 WHERE num_col = v_Numbers(v_Count);
26 EXCEPTION
27 WHEN OTHERS THEN
28 DBMS_OUTPUT.PUT_LINE('Got exception: ' || SQLERRM);
29 v_NumErrors := SQL%BULK_EXCEPTIONS.COUNT;
30 DBMS_OUTPUT.PUT_LINE(
31 'Number of errors during processing: ' || v_NumErrors);
32 FOR v_Count IN 1..v_NumErrors LOOP
33 DBMS_OUTPUT.PUT_LINE('Error ' || v_Count || ', iteration ' ||
34 SQL%BULK_EXCEPTIONS(v_Count).error_index || ' is: ' ||
35 SQLERRM(0 - SQL%BULK_EXCEPTIONS(v_Count).error_code));
36 END LOOP;
37
38 COMMIT;
39 END;
40 /
Got exception: ORA-24381: error(s) in array DML
Number of errors during processing: 1
Error 1, iteration 6 is: ORA-12899: value too large for column (actual: , maximum: )
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> drop table MyTable;
Table dropped.
SQL>
0 0
- The SAVE EXCEPTIONS clause will record any exception during the bulk operation, and continue process
- tools save the logs during su procedure
- 【译】Why JavaScript Is and Will Continue to Be the First Choice of Programmers
- Difference between the having clause and the group by statement
- autohotke Save any bitmaps on the clipboard to file
- [Symfony\Component\Process\Exception\RuntimeException] The Proc
- ERROR 000953: Extent of the overlay operation will be empty.
- 【ENVI错误】 OBJ_NEW:Error encoutered during the sparse operation
- openwrt The process did not produce any response
- KS GL journal [0807015] cannot do any operation and Fund status is In Process
- Windows CE: Save and Restore the Registry
- Java04 save and read the .txt
- What Employers Are Looking For During The Interview Process
- What is the difference between --save and --save-dev?
- The WITH Clause
- The FOR UPDATE Clause
- A problem during the compilation of Lemur and the solution
- 'Operation is not valid due to the current state of the object' error during postback
- 提取字符串中的数字
- java--去银行
- weixinbridgejs
- iPad容量与价格里的猫腻
- 讲解YCbCr
- The SAVE EXCEPTIONS clause will record any exception during the bulk operation, and continue process
- Testng 的数据源 驱动测试 代码与配置
- 输出旋转方形数字图形
- 选显卡切换内容 for以及数组的巧妙运用
- oracle数据库的配置管理与自动发布实现
- 苹果最新操作系统将这样改变人们工作生活方式
- Python中dict使用
- Linux的pthread_concurrency(int leavels)
- linux定时执行java程序