FORALL

Description

The FORALL statement runs one DML statement multiple times, with different values in the VALUES and WHERE clauses. (Oracle PL/SQL Language Reference FORALL Statement).

FORALL index IN bounds_clause [ SAVE ] [ EXCEPTIONS ] dml_statement ;

Sample Source Patterns

Setup Data

Oracle

CREATE TABLE table1 (
    column1 NUMBER,
    column2 NUMBER
);

INSERT INTO table1 (column1, column2) VALUES (1, 2);
INSERT INTO table1 (column1, column2) VALUES (2, 3);
INSERT INTO table1 (column1, column2) VALUES (3, 4);
INSERT INTO table1 (column1, column2) VALUES (4, 5);
INSERT INTO table1 (column1, column2) VALUES (5, 6);

CREATE TABLE table2 (
    column1 NUMBER,
    column2 NUMBER
);

INSERT INTO table2 (column1, column2) VALUES (1, 2);

Snowflake

1. FORALL With Collection of Records

Oracle

Snowflake

The EWIs MSCCP0005 and MSCCP0006 are added in every FETCH BULK COLLECT occurrence into FORALL statement.

2. FORALL With INSERT INTO

Oracle

Snowflake

3. FORALL With Multiple Fetched Collections

Oracle

Snowflake

4. FORALL With Record of Collections

Oracle

Snowflake

5. FORALL With Dynamic SQL

Oracle

Snowflake

6. FORALL With Literal SQL

Oracle

Snowflake

7. FORALL With Parametrized Cursors

Oracle

Snowflake

8. FORALL Without LOOPS

Oracle

Snowflake

9. FORALL With UPDATE Statements

Oracle

Snowflake

10. FORALL With DELETE Statements

Oracle

Snowflake

11. FORALL With PACKAGE References

Oracle

Snowflake

12. FORALL With MERGE Statements

Oracle

Snowflake

13. Default FORALL transformation

You might also be interested in Bulk Cursor Helpers.

Oracle

Snowflake

This transformation is done only when none of the previously mentioned transformations can be done.

14. Multiple FORALL inside a LOOP clause

This pattern applies when there is more than one FORALL in the same procedure and it meets the following structure.

Oracle

Snowflake

15. Multiple FORALL inside different LOOP clauses

This pattern applies when there is more than one FORALL in the same procedure and it meets the following structure.

Oracle

Snowflake

16. FORALL with MERGE INTO with LOG ERRORS

Oracle

Snowflake

17. FORALL with INSERT with LOG ERRORS

Oracle

Snowflake

  1. MSCCP0004: This statement has usages of dynamic SQL.

  2. MSCCP0005: This statement has usages of cursor fetch bulk operations.

  3. MSCCP0006: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.

Last updated

Was this helpful?