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

.IF ACTIVITYCOUNT <> 0 THEN .GOTO InsertEmployee;
EXECUTE IMMEDIATE
$$
  DECLARE
    STATUS_OBJECT OBJECT;
  BEGIN
    IF (STATUS_OBJECT['SQLROWCOUNT'] != 0) THEN
      /*** MSC-WARNING - MSCEWI2072 - LABEL InsertEmployee NOT FOUND, GOTO InsertEmployee WAS REPLACED WITH RETURN STATEMENT ***/
       
      RETURN 1;
    END IF;
  END
$$

Last updated