IF, ELSE, and ENDIF - Parallel Data Pump

Teradata Parallel Data Pump Reference

Product
Parallel Data Pump
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-3021
lifecycle
previous
Product Category
Teradata Tools and Utilities

IF, ELSE, and ENDIF

Purpose  

Teradata TPump provides a structure of IF, ELSE, and ENDIF commands for the conditional control of execution processes. Conditional execution works as follows:

Syntax  

where

 

Syntax Element

Description

conditional expression

Userdefined variables or predefined system variables following the IF command, whose condition (TRUE or FALSE) triggers the execution of alternative groups of statements

statements to execute if TRUE

Statements to be executed whenever the conditional expression following the IF command evaluates as TRUE

statements to execute if FALSE

Statements following the optional ELSE command which execute only when the conditional expression following the IF command evaluates as FALSE

statements to resume with

Statements following the ENDIF command to terminate the conditional statement execution process and resume the normal command sequence

Usage Notes  

The conditional expression in the IF command may consist of either user‑defined variables or predefined system variables.

The ELSE command clause is optional. ELSE is used only when there are statements to be executed when the condition is evaluated as false. Conditional expression is an expression which can be evaluated as either true or false. When evaluation of the expression returns a numeric result, 0 is interpreted as false; nonzero results are interpreted as true. See “Utility Variables” on page 66.

Teradata TPump supports the nesting of IF commands to a level of 100.

Any ELSE or ENDIF commands must be present in their entirety and cannot be composed simply of variables in need of substitution.

Commands and statements following an IF, ELSE, or ENDIF structure that are not executed are not parsed and do not have their variables substituted.

Example  

Teradata TPump is case sensitive when doing a compare on an &SYS system variable. The RUN FILE command does not execute because the substituted values returned in this example are all in uppercase. This factor must be considered when creating a script to force the execution of a predetermined sequence of events. If, in line 0003, 'FRI' was used, the compare would work and the RUN FILE command would execute.

0003 .IF '&SYSDAY' = 'Fri' THEN;
14:10:28  FRI MAY 09, 1997
UTY2402 Previous statement modified to:
0004 .IF 'FRI' = 'Fri' THEN;
0005 .RUN FILE UTNTS38;
0006 .ENDIF;  

Example  

In Example 2, the user has created the table named &TABLE and a variable named CREATERC, into which is set the system return code resulting from the execution of the CREATE TABLE statement. If the table name has not already been used, and the return code is not zero, the return code evaluates to an error condition and the job logs off with the error code displayed.

0010 .SET CREATERC TO &SYSRC;
0011 .IF &CREATERC = 3803 /* Table &TABLE already exists */ THEN;
UTY2402 Previous statement modified to:
0012 .LOGOFF 08;
0013 .RUN FILE RUN01;
0014 .ELSE
0015 .IF &CREATERC <> 0 THEN
0016 .LOGOFF &CREATRC;
0017 .ENDIF