if and else condition in bteq

Analytics
N/A

if and else condition in bteq

hi , can any one help me,, how to use if and else condition in bteq,,,
3 REPLIES
Teradata Employee

Re: if and else condition in bteq

Hello,

You need to put a dot "." before IF as follows:

.IF ACTIVITYCOUNT = 0 THEN .QUIT 65;

HTH.

Regards,

Adeel
SN
N/A

Re: if and else condition in bteq

just to add to it...

while using IF...THEN - when the condition evaluates to false, the it ignores the action in THEN clause and proceeds with the next command. so, nor explicit ELSE stmt with BTEQ IF...THEN but its obvious.

thx
N/A

Re: if and else condition in bteq

If you want to prove a method related with IF- ELSE but with Querys maybe this example can help you:

.LOGON IPSERVER/USR,PASSWORD; 

SELECT TOP 10 * FROM DB.TABLE; --Q1

.IF ERRORCODE !=0 THEN .GOTO DoQuery1; 

.IF ERRORCODE =0 THEN  .GOTO DoQuery2;

.LABEL DoQuery1; 

     SELECT TOP 1 * FROM DB.TABLE;  --Q2

    .GOTO End;

.LABEL DoQuery2; 

     SELECT TOP 2 * FROM DB.TABLE; --Q3 

    .GOTO End;

.LABEL End;

.LOGOFF; 

.EXIT; 

Depending of the result of Q1, the sequence of the bteq will be defined, if it goes to DoQuery1 or DoQuery2, but it's very important put de command .GOTO End to keep de estructure of the method IF-ELSE, if you don´t put it you can enter in a sequence where your code will process both Query´s (first Q2 and then Q3).