INIT_CURSOR_UDF

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