Bulk Cursor Helpers

These procedures and functions are used to simulate the behavior of a CURSOR with bulk operations.

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.

You might also be interested in Default FORALL transformation.

The Cursor is simulated with an OBJECT with different information regarding the state of the cursor. A temporary table is created to store the result set of the cursor's query.

Most of these Procedures return a new Object with the updated state of the cursor.

INIT_CURSOR

This function initializes a new object with the basic cursor information

CREATE OR REPLACE FUNCTION INIT_CURSOR(NAME VARCHAR, QUERY VARCHAR)
RETURNS OBJECT
AS
$$
  SELECT OBJECT_CONSTRUCT('NAME', NAME, 'ROWCOUNT', -1, 'QUERY', QUERY, 'ISOPEN', FALSE, 'FOUND', NULL, 'NOTFOUND', NULL)
$$;

OPEN_BULK_CURSOR

These procedures creates a temporary table with the query of the cursor. An optional overload exists to support bindings.

CLOSE_BULK_CURSOR

This procedure deletes the temporary table that stored the result set of the cursor and resets the cursor's properties to their initial state.

FETCH Helpers

Due to Oracle being capable of doing the FETCH statement on different kind of scenarios, a multiple procedures with overloads were created to handle each case. These helpers save the fetched values into the RESULT property in the CURSOR object.

Some of the overloads include variations when the LIMIT clause was used or not. Other overloads have a COLUMN_NAMES argument that is necessary when the FETCH statement is being done into a variable that has or contains a records with column names that are different to the column names of the query.

FETCH_BULK_COLLECTION_RECORDS

These procedures are used when a FETCH BULK is done into a collection of records.

FETCH_BULK_COLLECTIONS

These procedures are used when the FETCH statement is done into one or multiple collections. Since the columns are specified in this FETCH operation, an override for specific COLUMN_NAMES is not necessary.

FETCH_BULK_RECORD_COLLECTIONS

These procedures are used when a FETCH BULK is done into a record of collections.

Last updated