Translation references to convert Teradata BTEQ files to Snowflake SQL
Description
Some parts in the output code are omitted for clarity reasons.
Basic Teradata Query (BTEQ) is a general-purpose, command-based program that enables users on a workstation to communicate with one or more Teradata Database systems and to format reports for both print and screen output.
The BTEQ content is relocated within an EXECUTE IMMEDIATE block of to transfer the BTEQ script functionality to Snowflake SQL executable code.
All the DML and DDL statements inside BTEQ scripts are supported by SnowConvert and successfully translated to Snowflake SQL. The commands that do not have support yet, or do not have support at all, are being marked with a warning message and commented out.
EXECUTEIMMEDIATE$$DECLARE STATUS_OBJECT OBJECT := OBJECT_CONSTRUCT('SQLCODE', 0);BEGIN-- Additional Params: -q SnowScript--.LOGON 0/dbc,dbc !!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'BTLogOn' NODE ***/!!!null;BEGINUSEDATABASE tduser; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;BEGINCREATE OR REPLACETABLEemployee_bkup ( EmployeeNo INTEGER, FirstName CHAR(30), LastName CHAR(30), DepartmentNo SMALLINT, NetPay INTEGER,UNIQUE (EmployeeNo) ); STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;BEGINDROPTABLE employee_bkup; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT); EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END; IF (STATUS_OBJECT['SQLCODE'] /*** SSC-FDM-TD0013 - THE SNOWFLAKE ERROR CODE MISMATCH THE ORIGINAL TERADATA ERROR CODE ***/ != 0) THEN
RETURN STATUS_OBJECT['SQLCODE'] /*** SSC-FDM-TD0013 - THE SNOWFLAKE ERROR CODE MISMATCH THE ORIGINAL TERADATA ERROR CODE ***/;
ENDIF;--.LOGOFF !!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'LogOff' NODE ***/!!!null;END$$
2. Bash Variable Placeholders Example
SnowConvert supports the migration of BTEQ code with Bash Variable Placeholders used for shell scripts, these placeholders will be migrated to its SnowSQL equivalent and SSC-FDM-TD0003 will be added to the code. Please consider the following when migrating code with these placeholders:
SnowConvert does not support the migration of shell scripts, to migrate the BTEQ code please isolate it in a BTEQ file and supply it as input for the tool.
SnowSQL with variable substitution enabled is required to execute the migrated code, for more information on how to use SnowSQL please check SSC-FDM-TD0003 and the official documentation for SnowSQL.
IN -> Teradata_02.bteq
-- Additional Params: -q SnowScript.LOGON dbc, dbc;DATABASE testing;SELECT $columnVar FROM $tableVar WHERE col2 = $nameExprVar;INSERTINTO $tableName values ('$myString', $numValue);UPDATE $dbName.$tableName SET col1 = $myValue;DELETEFROM $tableName;.LOGOFF;
OUT -> Teradata_02.sql
EXECUTE IMMEDIATE$$ --** SSC-FDM-TD0003 - BASH VARIABLES FOUND, USING SNOWSQL WITH VARIABLE SUBSTITUTION ENABLED IS REQUIRED TO RUN THIS SCRIPT **
DECLARE STATUS_OBJECT OBJECT := OBJECT_CONSTRUCT('SQLCODE', 0);BEGIN-- Additional Params: -q SnowScript--.LOGON dbc, dbc !!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'BTLogOn' NODE ***/!!!null;BEGIN USE DATABASE testing; STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT);EXCEPTIONWHEN OTHER THEN STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);END;BEGINSELECT &columnVarFROM