Using Conditional Logic in a Query - Teradata SQL Assistant

Teradata® SQL Assistant for Windows User Guide

Teradata SQL Assistant
Release Number
October 2018
English (United States)
Last Update
Product Category
Teradata Tools and Utilities

Table Legend

  • { } – Items in curly brackets are requirements.
  • [ ] – Items in square brackets are optional.
  • label – A string that does not contain any blank spaces or tabs.
  • oper – One of the following operators:
    = > < >= <=
    <> != ^= ~=  
  • n – An integer.
  • value – Any string.
  • filename – A fully qualified file name.
Command Description

If the condition is true, the action is performed. Otherwise the flow continues to the following statement.

This command cannot be used before the first SQL statement.

.GOTO label
The next statement executed is the statement following the .LABEL command.
.LABEL label
Defines the destination of a .GOTO command.

Execution terminates at this command. The optional parameter is used as the result code for the query. Zero indicates a successful query, any other value indicates failure.
Performs the same function as the .EXIT command.
.SET value
This command is for BTEQ compatibility only. This command is ignore. Unlike BTEQ, The .SET prefix is required for Teradata SQL Assistant to recognize and ignore a command.
.RUN filename
Executes the query contained in the specified filename. The RUN command must be the first and only statement executed.

Usage Notes

  • The period (.) before the RUN command is optional for backward compatibility.
  • The period (.) before other commands (except .SET) is optional when connected to a Teradata Database, but required when connected to other databases.
  • The period for the .SET command is mandatory even when connected to a Teradata Database.
  • [Optional] All commands can be followed by a semi-colon. This is not required unless you need compatibility with BTEQ.
  • To use conditional logic commands based on the ERRORCODE, you must first disable the Stop query execution if an SQL error occurs option on the Query tab of the Options dialog. Otherwise, Teradata SQL Assistant might stop processing the query before it attempts to evaluate your conditional logic. See Setting Query Options.