SSC-PRF-0004

This statement has usages of cursor for loop

circle-info

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentationarrow-up-right

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected]envelope.

Thank you for your understanding.

Severity

None

Description

This warning is used to indicate that the statement has usages of cursor for loop. A cursor for loop is a control structure that allows to iterate over the result set one row at a time.

This scenario could be considered a complex pattern when the code inside the loop is overly complex. E.g. if the SELECT statement inside the cursor for loop returns a large result set, or if the code inside the loop involves complex operations or nested loops, the cursor for loop could become slow and inefficient. This warning is meant to be a helper to spot some problems that a static-code analyzer such as SnowConvert cannot.

Code Example

Teradata

IN -> Teradata_01.sql
REPLACE PROCEDURE teradata_cursor_for_loop()    
BEGIN
    FOR fUsgClass AS cUsgClass CURSOR FOR
        (SELECT col1
        FROM sample_table)
    DO
        SET var1 = fUsgClass.col1;
    END FOR;
END;

Oracle

Recommendations

Last updated