DECLARE REFCURSOR

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 Documentation

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

Thank you for your understanding.

Description

A refcursor data type simply holds a reference to a cursor. You can create a cursor variable by declaring it as a variable of type refcursor

(Redshift SQL Language Reference Refcursor Declaration)

Grammar Syntax

DECLARE
name refcursor;

Since Snowflake does not support the REFCURSOR data type, its functionality is replicated by converting the REFCURSOR variable into a RESULTSET type. The query used to open the REFCURSOR is assigned to the RESULTSET variable, after which a new cursor is created and linked to the RESULTSET variable. Additionally, all references to the original REFCURSOR within the cursor logic are updated to use the new cursor, thereby replicating the original functionality.

Sample Source Patterns

Case: Single use

Input Code:

Output Code:

Case: Cursor with Dynamic Sql

Input Code:

Output Code:

Case: Multiple uses:

Input Code:

Output Code:

Known Issues

There are no known issues.

There are no related EWIs.

Last updated