EXIT

Translation reference to convert Oracle EXIT statement to Snowflake Scripting

circle-info

Some parts in the output code are omitted for clarity reasons.

Description

The EXIT statement exits the current iteration of a loop, either conditionally or unconditionally, and transfers control to the end of either the current loop or an enclosing labeled loop. (Oracle PL/SQL Language Reference EXIT Statementarrow-up-right)

EXIT [ label ] [ WHEN boolean_expression ] ;
{ BREAK | EXIT } [ <label> ] ;

Sample Source Patterns

circle-info

Note that you can change EXITwith BREAKand everything will work the same.

1. Simple Exit

Code skips the INSERT statement by using EXIT.

circle-check

Oracle

IN -> Oracle_01.sql
CREATE TABLE exit_testing_table_1 (
    iterator VARCHAR2(5)
);

CREATE OR REPLACE PROCEDURE exit_procedure_1
IS
I NUMBER := 0;
J NUMBER := 20;
BEGIN
    WHILE I <= J LOOP
        I := I + 1;
        EXIT;
        INSERT INTO exit_testing_table_1 VALUES(TO_CHAR(I));
    END LOOP;  
END;

CALL exit_procedure_1();
SELECT * FROM exit_testing_table_1;

Snowflake Scripting

2. Exit with condition

Code exits the loop when the iterator is greater than 5.

circle-check

Oracle

Snowflake Scripting

3. Exit with label and condition

Code breaks both loops by using the EXIT statement pointing to the outer loop.

circle-check
circle-info

Note that labels are going to be commented out.

Oracle

Snowflake Scripting

Known Issues

No issues were found.

  1. SSC-EWI-0094: Label declaration not supported.

Last updated