PREPARE

Translation specification to convert Teradata PREPARE statement to Snowflake Scripting. This section review the PREPARE pattern related to a cursor logic.

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

Prepares the dynamic DECLARE CURSOR statement to allow the creation of different result sets. Allows dynamic parameter markers.

For more information, please review the following documentation.

Tedarata syntax:

PREPARE statement_name FROM { 'statement_string' | statement_string_variable } ;

Where:

  • statement_name is the same identifier as statement_name in a DECLARE CURSOR statement.

  • statement_string is the SQL text that is to be executed dynamically.

  • statement_string_variable is the name of an SQL local variable, or an SQL parameter or string variable, that contains the SQL text string to be executed dynamically.

Important information

For this transformation, the cursors are renamed since they cannot be dynamically updated.

Sample Source Patterns

Data setting for examples

For this example, please use the following complementary queries in the case that you want to run each case.

Simple scenario

This example reviews the functionality for the cases where a single cursor is being used one single time.

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Simple scenario with RETURN ONLY

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Reused cursor case

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Modified query before usage

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Simple cursor combined with no PREPARE pattern

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Prepare combined with nested cursors

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Variable markers without variable reordering

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Variable markers with variable reordering

When there are variables setting the value into different ones between the PREPARE statement and OPEN cursor in Teradata, It is necessary to move this variable before the EXECUTE IMMEDIATE in Snowflake. So, the dynamic variable information is updated at the moment of running the dynamic query.

Teradata

Snowflake Scripting

Usages for cursors must be renamed and declared again.

Anonymous blocks - Declaration outside the block

Teradata

Known Issues

  • Review carefully nested cursors and conditionals, if that is the case.

No related EWIs.

Last updated