INIT_CURSOR_UDF

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.

Definition

This user-defined function (UDF) is to initialize a cursor object with the equivalent functionality.

INIT_CURSOR_UDF(NAME VARCHAR, QUERY VARCHAR)

Parameters

NAME VARCHAR

The name of the cursor.

QUERY VARCHAR

The query that is associated with the cursor.

Returns

Returns an object with the cursor information.

Usage example

Input:

CREATE OR REPLACE TABLE BULKCOLLECTTABLE(test VARCHAR(100));

CREATE OR REPLACE PROCEDURE MY_PROCEDURE ()
RETURNS OBJECT
LANGUAGE SQL
EXECUTE AS CALLER
AS
$$
    DECLARE
        MY_CURSOR OBJECT := INIT_CURSOR_UDF('MY_CURSOR', '   SELECT * FROM
      BULKCOLLECTTABLE');

    BEGIN
        Return MY_CURSOR;
    END;
$$;

CALL MY_PROCEDURE();

Output:

{
  "ISOPEN": false,
  "NAME": "MY_CURSOR",
  "QUERY": "   SELECT * FROM\n      BULKCOLLECTTABLE",
  "ROWCOUNT": -1
}

Last updated