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 Statementarrow-up-right).

FORALL index IN bounds_clause [ SAVE ] [ EXCEPTIONS ] dml_statement ;
circle-exclamation

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

circle-check

Snowflake

circle-info

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

circle-exclamation

12. FORALL With MERGE Statements

Oracle

Snowflake

circle-exclamation

13. Default FORALL transformation

circle-info

You might also be interested in Bulk Cursor Helpers.

Oracle

Snowflake

circle-info

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

14. Multiple FORALL inside a LOOP clause

circle-info

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

circle-info

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

circle-exclamation

Oracle

Snowflake

17. FORALL with INSERT with LOG ERRORS

circle-exclamation

Oracle

Snowflake

  1. MSCCP0004arrow-up-right: This statement has usages of dynamic SQL.

  2. MSCCP0005arrow-up-right: This statement has usages of cursor fetch bulk operations.

  3. MSCCP0006arrow-up-right: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.

Last updated

Was this helpful?