SnowConvert AI - Teradata - SnowConvert AI Procedures Helpers¶
In this section you will find the helper functions used inside procedures that are used to achieve functional equivalence of some Teradata features that are not supported natively in Snowflake.
Cursor Helper¶
This section describes the usage of different functions to achieve functional equivalence for Teradata cursors in JavaScript.
The cursor helper is a function that contains the main four actions that Teradata cursors perform such as Open, Fetch, Next, and Close.
CURSOR(), the main routine which declares the needed variables and other sub-routines.
OPEN(), opens the cursor executing the given statement, and updates the necessary variables.
NEXT(), moves the cursor to the next row (if any) of the statement and sets every column value to the current row.
FETCH(), obtains the values (if any) from the response of the statement executed.
CLOSE(), removes the temporary table from the _OUTQUERIES (if it was added in the EXEC helper) and unsets the necessary variables.
Note
Some parts of the output code are omitted for clarity reasons.
Cursor Sample Usage¶
Teradata
Snowflake output
Cursor Helper Function Definition¶
Known Issues ¶
No issues were found.
Exec Helper¶
The exec helper is a function used to execute SQL statements in procedures.
Syntax¶
EXEC(stmt)
EXEC(stmt, binds)
EXEC(stmt, binds, noCatch)
EXEC(stmt, binds, noCatch, catchFunction)
EXEC(stmt, binds, noCatch, catchFunction, opts)
Parameters¶
stmt¶
The string of the SQL statement to execute.
binds (optional)¶
An array with the values or the variables to bind into the SQL statement.
NoCatch (optional)¶
Boolean to know if an error should not be catched.
catchFunction (optional)¶
A function to execute in case an error occurs during the execution of the exec function.
opts (optional)¶
A JSON object ({ temp : true }) to know if the query ID should be returned.
FixBind And FormatDate Functions¶
The Exec helper uses a function defined in the helpers called FixBind. This function uses the FormatDate function when it encounters that one of the binding variables is a date type, this is done to manage properly the date types in Snowflake.
Both functions are defined as below.
Note
Some parts of the output code are omitted for clarity reasons.
Exec Usage Sample¶
Teradata
Snowflake output
Exec Helper Definition¶
Known Issues ¶
No issues were found.
Related EWIs ¶
No related EWIs.
Functional Equivalence Helpers¶
A list of helpers functions in JavaScript that procedures in Snowflake can use, in order to better support several Teradata language features.
Depending on what is in each Stored Procedure in Teradata, SnowConvert AI will create one or more of the following javascript functions inside them.
CompareDates¶
A function that compares dates handling nullity. In Javascript, it is needed to call .getTime() for date comparisons.
BetweenFunc¶
A function to handle the BETWEEN statement in Teradata.
LikeFunction()¶
A function to handle the LIKE statement in Teradata.
ERROR_HANDLERS()¶
The main error-handling routine.
INSERT_TEMP¶
Warning
This helper has been deprecated in stored procedures since version 2.0.15.
A function to create a temporary table using the argument query with the given parameters.
IS_NOT_FOUND()¶
A function that validates when a SELECT returns no values or a sentence affects zero rows. This is done in order to emulate the same behavior as Teradata, when there are exits or continue handlers for NOT FOUND EXCEPTIONS.
HANDLE_NOTFOUND()¶
This function uses the above IS_NOT_FOUND function to validate when an artificial error ‘NOT FOUND’ is being thrown.
PROCRESULTS()¶
A function that takes zero or multiple output parameters and binds them with the _OUTQUERIES in an array in order to be returned.
Known Issues ¶
No issues were found.
Related EWIs ¶
No related EWIs.
Into Helper¶
The into function is used to extract the resulting rows from a subquery or from a select into statement.
Fetch Function¶
The INTO helper uses a fetch function to get the row from a resulting query. The definition of the Fetch Function is described below.
Note
Some parts of the output code are omitted for clarity reasons.
Into Sample Usage¶
Teradata
Snowflake output
Into Helper function Definition¶
Known Issues ¶
No issues were found.
Related EWIs ¶
No related EWIs.