GOTO Translation reference for the conversion of Goto command to Snowflake Scripting
Description
The BTEQ Goto command skips over all intervening BTEQ commands and SQL statements until a specified label is encountered, then resumes processing as usual. (Teradata Basic Query Reference Goto Command )
Sample Source Patterns
Basic GOTO example
Snowflake scripting doesn't have an equivalent statement for Teradata BTEQ Goto command, but fortunately it can be removed from the input code and get an equivalent code, due to the sequence of Goto and Labels commands in reverse topological order always. In other words, the definitions come after their uses. Thus, Snowconvert just needs to copy bottom-up all Label section code to its corresponding Goto statements.
Teradata BTEQ
Copy -- Additional Params: -q SnowScript
.LOGON 0 / dbc,dbc;
DATABASE tduser;
.LOGON 127 . 0 . 0 . 1 / dbc,dbc;
INSERT INTO TABLEB VALUES ( 1 );
. IF activitycount = 0 then . GOTO SECTIONA
. IF activitycount >= 1 then . GOTO SECTIONB
.label SECTIONA
.REMARK 'Zero Hours on Account'
. GOTO SECTIONC
.label SECTIONB
.REMARK 'Total Hours on Account'
.label SECTIONC
.logoff
.exit
Snowflake
Copy EXECUTE IMMEDIATE
$$
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 ;
BEGIN
USE DATABASE tduser;
STATUS_OBJECT : = OBJECT_CONSTRUCT( 'SQLROWCOUNT' , SQLROWCOUNT);
EXCEPTION
WHEN OTHER THEN
STATUS_OBJECT : = OBJECT_CONSTRUCT( 'SQLCODE' , SQLCODE, 'SQLERRM' , SQLERRM, 'SQLSTATE' , SQLSTATE);
END ;
--.LOGON
!!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'BTLogOn' NODE ***/ !!!
null ;
/*** SSC-EWI-0001 - UNRECOGNIZED TOKEN ON LINE '4' COLUMN '8' OF THE SOURCE CODE STARTING AT '127.0'. EXPECTED 'STATEMENT' GRAMMAR. LAST MATCHING TOKEN WAS 'LOGON' ON LINE '4' COLUMN '2'. FAILED TOKEN WAS '127.0' ON LINE '4' COLUMN '8'. CODE '81'. ***/
/*--127.0.0.1/dbc,dbc*/
BEGIN
INSERT INTO TABLEB
VALUES ( 1 );
STATUS_OBJECT : = OBJECT_CONSTRUCT( 'SQLROWCOUNT' , SQLROWCOUNT);
EXCEPTION
WHEN OTHER THEN
STATUS_OBJECT : = OBJECT_CONSTRUCT( 'SQLCODE' , SQLCODE, 'SQLERRM' , SQLERRM, 'SQLSTATE' , SQLSTATE);
END ;
IF ( NOT (STATUS_OBJECT['SQLROWCOUNT'] = 0 )) THEN
--** SSC-FDM-TD0026 - GOTO SECTIONA WAS REMOVED DUE TO IF STATEMENT INVERSION **
IF (STATUS_OBJECT['SQLROWCOUNT'] >= 1 ) THEN
/*.label SECTIONB*/
--.REMARK 'Total Hours on Account'
null ;
/*.label SECTIONC*/
--.logoff
null ;
RETURN 0 ;
END IF ;
END IF ;
/*.label SECTIONA*/
--** SSC-FDM-0027 - REMOVED NEXT STATEMENT, NOT APPLICABLE IN SNOWFLAKE. **
--.REMARK 'Zero Hours on Account'
!!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'Remark' NODE ***/ !!!
null ;
/*.label SECTIONC*/
--.logoff
null ;
RETURN 0 ;
/*.label SECTIONB*/
--** SSC-FDM-0027 - REMOVED NEXT STATEMENT, NOT APPLICABLE IN SNOWFLAKE. **
--.REMARK 'Total Hours on Account'
!!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'Remark' NODE ***/ !!!
null ;
/*.label SECTIONC*/
--** SSC-FDM-0027 - REMOVED NEXT STATEMENT, NOT APPLICABLE IN SNOWFLAKE. **
--.logoff
!!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'LogOff' NODE ***/ !!!
null ;
RETURN 0 ;
END
$$
Known Issues
No issues were found.
Related EWIS
SSC-EWI-0001 : Unrecognized token on the line of the source code.
SSC-FDM-0027 : Removed next statement, not applicable in SnowFlake.
SSC-FDM-TD0026 : GOTO statement was removed due to if statement inversion.
Last updated 3 months ago