diff --git a/product_docs/docs/epas/17/application_programming/epas_compat_spl/12_working_with_collections/03_using_the_forall_statement.mdx b/product_docs/docs/epas/17/application_programming/epas_compat_spl/12_working_with_collections/03_using_the_forall_statement.mdx index 1b0d8f202be..78a0ea9d18f 100644 --- a/product_docs/docs/epas/17/application_programming/epas_compat_spl/12_working_with_collections/03_using_the_forall_statement.mdx +++ b/product_docs/docs/epas/17/application_programming/epas_compat_spl/12_working_with_collections/03_using_the_forall_statement.mdx @@ -19,7 +19,7 @@ FORALL IN .. Optionally, `SAVE EXCEPTIONS` allows a FORALL statement to continue even if any of the DML statements fail. When a DML statement fails, SPL doesn't raise an exception, it saves information about the failure. After the FORALL statement completes, SPL raises a single exception for the FORALL statement. The error information is stored in the collection of records called `SQL%BULK_EXCEPTIONS`, where: - - `SQL%BULK_EXCEPTIONS(i).ERROR_INDEX` records the number of the DML statement that failed. + - `SQL%BULK_EXCEPTIONS(i).ERROR_INDEX` records the nth number of the DML statement that failed. - `SQL%BULK_EXCEPTIONS(i).ERROR_CODE` records the database error code for the failure. - `SQL%BULK_EXCEPTIONS.COUNT` records the total number of the DML statements that failed. @@ -177,7 +177,7 @@ a | b ## Using FORALL with SAVE EXCEPTIONS -This example merges (inserts and updates) the records of test_table2 using `FORALL` statement: +This example shows how to use the `SAVE EXCEPTIONS` clause with the `FORALL` statement: ```sql CREATE TABLE foo(id NUMBER(6) not null, name VARCHAR2(20)); @@ -186,49 +186,22 @@ INSERT INTO foo values(1, 'Peter'); ```sql DECLARE - TYPE namelist_t IS TABLE OF VARCHAR2 (5000); - - names_with_errors namelist_t - - := namelist_t (RPAD ('ABCD', 1000, 'ABC'), - - 'George', - - RPAD ('ABCD', 3000, 'ABC'), - - 'Max'); - - - + names_with_errors namelist_t := namelist_t (RPAD ('ABCD', 1000, 'ABC'),'George',RPAD ('ABCD', 3000, 'ABC'),'Max'); ex_dml_errors EXCEPTION; - - PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381); - - + PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381); BEGIN - FORALL indx IN 1 .. names_with_errors.COUNT SAVE EXCEPTIONS - - UPDATE foo SET name = names_with_errors (indx); - - + UPDATE foo SET name = names_with_errors (indx); EXCEPTION - - WHEN ex_dml_errors THEN - + WHEN ex_dml_errors THEN -- Handling exceptions - - FOR i IN 1..SQL%BULK_EXCEPTIONS.COUNT LOOP - - DBMS_OUTPUT.PUT_LINE('SAVE EXCEPTIONS: The Error at ' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX || - - ' Error Code ' || SQL%BULK_EXCEPTIONS(i).ERROR_CODE); - - END LOOP; - + FOR i IN 1..SQL%BULK_EXCEPTIONS.COUNT LOOP + DBMS_OUTPUT.PUT_LINE('SAVE EXCEPTIONS: The Error at ' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX || + ' Error Code ' || SQL%BULK_EXCEPTIONS(i).ERROR_CODE); + END LOOP; END; __OUTPUT__