CURSOR
Translation reference to convert Teradata CURSOR statement to Snowflake Scripting
Description
A cursor is a data structure that is used by stored procedures at runtime to point to a resultset returned by an SQL query. For more information check here.
Sample Source Patterns
Setup Data
The following code is necessary to execute the sample patterns present in this section.
Basic Cursor
Teradata
Snowflake Scripting
Single Returnable Cursor
The following procedure is intended to return one result set since it has the DYNAMIC RESULT SETS 1
property in the header, the cursor has the WITH RETURN
property and is being opened in the body.
Teradata
Snowflake Scripting
Multiple Returnable Cursors
The following procedure is intended to return multiple results when DYNAMIC RESULT SETS
property in the header is greater than 1, the procedure has multiple cursors with the WITH RETURN
property and these same cursors are being opened in the body.
Teradata
Snowflake Scripting
Cursors With Binding Variables
The following cursor uses binding variables as the were condition to perform the query.
Teradata
Snowflake Scripting
Cursor For Loop
It is a type of loop that uses a cursor to fetch rows from a SELECT statement and then performs some processing on each row.
Teradata
Snowflake Scripting
Cursor Fetch inside a Loop
It allows one to retrieve rows from a result set one at a time and perform some processing on each row.
Teradata
Snowflake Scripting
Known Issues
The following parameters are not applicable in Snowflake Scripting.
1. Declare
[ SCROLL/NO SCROLL ] Snowflake Scripting only supports FETCH NEXT.
[ READ-ONLY ] This is the default in Snowflake Scripting.
[ UPDATE ].
2. Fetch
[ NEXT ] This is the default behavior in Snowflake Scripting.
[ FIRST ].
Related EWIs
SSC-FDM-0020: Multiple result sets are returned in temporary tables.
SSC-PRF-0003: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.
SSC-PRF-0004: This statement has usages of cursor for loop.
Last updated