IF... THEN...

Translation reference for the conversion of IF statements to Snowflake Scripting

Description

The IF statement validates a condition and executes an action when the action is true. (Teradata SQL Language reference IF...THEN...)

.IF <Condition> THEN <Action>;

<Condition> := <Status_variable> <Operator> Number
<Status_variable> := ACTIVITY_COUNT | ERRORCODE | ERRORLEVEL
<Operator> := ^= | != | ~= | <> | = | < | > | <= | >=
<Action> := BTEQ_command | SQL_request

Sample Source Patterns

Basic IF example

IN -> Teradata_01.bteq
-- Additional Params: -q SnowScript
.IF ACTIVITYCOUNT <> 0 THEN .GOTO InsertEmployee;
OUT -> Teradata_01.sql
EXECUTE IMMEDIATE
$$
  DECLARE
    STATUS_OBJECT OBJECT := OBJECT_CONSTRUCT('SQLCODE', 0);
  BEGIN
    IF (STATUS_OBJECT['SQLROWCOUNT'] != 0) THEN
       
      RETURN 1;
    END IF;
  END
$$

No related EWIs.

Last updated