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 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.
var CompareDates = function(value1, value2) {
var value1Time = value1 && value1.getTime() || null;
var value2Time = value2 && value2.getTime() || null;
if (value1Time == null && value2Time == null) return null; /*in SQL null == null is equal to null as well as any other comparison */
return value1Time > value2Time? 1 : value1Time<value2Time? -1 : 0;
}BetweenFunc
A function to handle the BETWEEN statement in Teradata.
var BetweenFunc = function (expression,startExpr,endExpr) {
if ([expression,startExpr,endExpr].some((arg) => arg == null)) {
return false;
}
return expression >= startExpr && expression <= endExpr;
};LikeFunction()
A function to handle the LIKE statement in Teradata.
ERROR_HANDLERS()
The main error-handling routine.
INSERT_TEMP
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.
Last updated
Was this helpful?