BEGIN END

Translation reference to convert Teradata BEGIN END clause to Snowflake Scripting

BEGIN END TRANSACTION

Description

Defines the beginning of an explicit logical transaction in Teradata session mode.

For more information regarding Teradata BEGIN END Transaction, check here.

[ BEGIN TRANSACTION | BT ]
     statement
     [ statement ]... ]
[ END TRANSACTION | ET ];

Sample Source Pattern

Teradata

IN -> Teradata_01.sql
REPLACE PROCEDURE BeginEndProcedure()
BEGIN
    DECLARE HELLOSTRING VARCHAR(60);
    BEGIN TRANSACTION
        SET HELLOSTRING = 'HELLO WORLD';
    END TRANSACTION;
END;

Snowflake Scripting

OUT -> Teradata_01.sql
CREATE OR REPLACE PROCEDURE BeginEndProcedure ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
    BEGIN
        LET HELLOSTRING VARCHAR(60);
        BEGIN TRANSACTION
        HELLOSTRING := 'HELLO WORLD';
        COMMIT;
    END;
$$;

BEGIN END REQUEST

Description

Delimits a SQL multistatement request

For more information regarding Teradata BEGIN END Request, check here.

BEGIN REQUEST
     statement
     [ statement ]... ]
END REQUEST;

Sample Source Pattern

Teradata

IN -> Teradata_02.sql
REPLACE PROCEDURE BeginEndProcedure()
BEGIN
    DECLARE HELLOSTRING VARCHAR(60);
    BEGIN REQUEST
        SET HELLOSTRING = 'HELLO WORLD';
    END REQUEST;
END;

Snowflake Scripting

OUT -> Teradata_02.sql
CREATE OR REPLACE PROCEDURE BeginEndProcedure ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
    BEGIN
        LET HELLOSTRING VARCHAR(60);
        BEGIN
            HELLOSTRING := 'HELLO WORLD';
            COMMIT;
        EXCEPTION
            WHEN OTHER THEN
                ROLLBACK;
        END;
    END;
$$;

BEGIN END COMPOUND

Description

Delimits a compound statement in a stored procedure.

For more information regarding Teradata BEGIN END Compound, check here.

label_name: BEGIN
     statement
     [ statement ]... ]
END label_name;

Sample Source Pattern

Teradata

IN -> Teradata_03.sql
REPLACE PROCEDURE BeginEndProcedure()
BEGIN
    DECLARE HELLOSTRING VARCHAR(60);
    label_name: BEGIN
        SET HELLOSTRING = 'HELLO WORLD';
    END label_name;
END;

Snowflake Scripting

OUT -> Teradata_03.sql
CREATE OR REPLACE PROCEDURE BeginEndProcedure ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
    BEGIN
        LET HELLOSTRING VARCHAR(60);
        !!!RESOLVE EWI!!! /*** SSC-EWI-0058 - FUNCTIONALITY FOR 'label_name LABEL' IS NOT CURRENTLY SUPPORTED BY SNOWFLAKE SCRIPTING ***/!!!
        label_name:
        BEGIN
            HELLOSTRING := 'HELLO WORLD';
        END;
    END;
$$;

Known Issues

1. Labels not supported in outer BEGIN END blocks

Teradata

IN -> Teradata_04.sql
REPLACE PROCEDURE procedureLabelSingle()
label_name: BEGIN
    DECLARE HELLOSTRING VARCHAR(60);
    SET HELLOSTRING = 'HELLO WORLD';
END label_name;

Snowflake Scripting

OUT -> Teradata_04.sql
CREATE OR REPLACE PROCEDURE procedureLabelSingle ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER