Nesting a multi-instruction (MI) IF under a single-instruction

Tools & Utilities
Enthusiast

Nesting a multi-instruction (MI) IF under a single-instruction

After TD driver update from 15.10 to 16.20 some code stopped working.

 

.if errorcode <> 0 then .if errorcode <> 3523 then .if errorcode <> 3624 .quit errorcode
*** Error: Nesting a multi-instruction (MI) IF under a single-instruction
(SI) IF..THEN is not allowed. If an MI IF was not intended,
review and correct the syntax as needed to ensure successful
THEN keyword parsing.
Terminating the application.

*** Exiting BTEQ...

*** RC (return code) = 16

 

Is there any workaroud for this or we have to rewrite it?

6 REPLIES 6
Highlighted
Teradata Employee

Re: Nesting a multi-instruction (MI) IF under a single-instruction

Hi. Please confirm that the last IF has always lacked a THEN keyword.

If so, BTEQ should have generated an error for that.

It may be that to add the new MI IF logic BTEQ had to become more strict.

 

Teradata Employee

Re: Nesting a multi-instruction (MI) IF under a single-instruction

And which BTEQ flavor ? Windows, Linux, MAC, z/OS ?

Teradata Employee

Re: Nesting a multi-instruction (MI) IF under a single-instruction

Using 12.00.00.02 solaris and 15.10.01.15 linux BTEQs I get the expected error for a missing THEN. See below. So I believe the correct thing to do is fix the syntax by adding a THEN keyword or actually rewrite the 3 IFS to be a single multi-condition IF.  For example...

.if ((errorcode<>0) AND (errorcode<>3523) AND (errorcode<>3624)) THEN .quit errorcode

 

That being said, I would most appreciate feedback on the BTEQ flavor and specific 15.10.01 version you were using so I can understand more about what happened.

 

 Teradata BTEQ 15.10.01.15 for LINUX. PID: 16599
 Copyright 1984-2019, Teradata Corporation. ALL RIGHTS RESERVED.
 Enter your logon or BTEQ command:
.if errorcode=0 then .if errorcode=0 then .if errorcode=0 .remark 'foo'

.if errorcode=0 then .if errorcode=0 then .if errorcode=0 .remark 'foo'
.if errorcode=0 then .if errorcode=0 .remark 'foo'
.if errorcode=0 .remark 'foo'
 *** Error: Expected a THEN keyword.


BTEQ 12.00.00.02 Fri Mar  8 10:32:43 2019
 
+---------+---------+---------+---------+---------+---------+---------+----

.set width 80
+---------+---------+---------+---------+---------+---------+---------+---------
.if errorcode=0 .remark 'foo'
 *** Error: Expected a THEN keyword.
+---------+---------+---------+---------+---------+---------+---------+---------
.if errorcode=0 then .remark 'foo'
.remark 'foo'
 foo
+---------+---------+---------+---------+---------+---------+---------+---------

.if errorcode=0 then .if errorcode=0 .remark 'foo'
.if errorcode=0 .remark 'foo'
 *** Error: Expected a THEN keyword.
+---------+---------+---------+---------+---------+---------+---------+---------
.if errorcode=0 then .if errorcode=0 then .remark 'foo'
.if errorcode=0 then .remark 'foo'
.remark 'foo'
 foo
+---------+---------+---------+---------+---------+---------+---------+---------

.if errorcode=0 then .if errorcode=0 then .if errorcode=0 .remark 'foo'
.if errorcode=0 then .if errorcode=0 .remark 'foo'
.if errorcode=0 .remark 'foo'
 *** Error: Expected a THEN keyword.
+---------+---------+---------+---------+---------+---------+---------+---------
.if errorcode=0 then .if errorcode=0 then .if errorcode=0 then .remark 'foo'
.if errorcode=0 then .if errorcode=0 then .remark 'foo'
.if errorcode=0 then .remark 'foo'
.remark 'foo'
 foo
+---------+---------+---------+---------+---------+---------+---------+---------

 

Enthusiast

Re: Nesting a multi-instruction (MI) IF under a single-instruction

I confirm that IF has always lacked a THEN keyword.

I actually think that driver might have been changed from version 14 not 15 as stated initially and I belive it is on AIX server.

I will confirm this with admins on Monday and will let you know.

Enthusiast

Re: Nesting a multi-instruction (MI) IF under a single-instruction

Suzanne, I got info than we upgraded from 14.10 -> 16.20 on AIX 7.1 , is adding THEN the only solution??

This could led to number of codes rewrites.

Teradata Employee

Re: Nesting a multi-instruction (MI) IF under a single-instruction

An SI IF statement without a THEN script has always been syntactically invalid and the tests I did last week show that. So to behave as expected, the script(s) should be fixed. My theory is that that the script has always been producing an error but for some reason it went overlooked -- perhaps due to inadvertent failure to route stderr to the same stream as stdout. That can reduce the chances of physically seeing an error message while vetting a new script. Adding a THEN is the only solution that will correct the script. Whether to collapse the nested IFs into one multi-condition IF rather than just add the missing THEN missing is a secondary consideration that I suggested just to make the script more concise. But I strongly encourage you to also investigate what stderr routing paradigm is being used as well as what testing was done to vet the script. If it was not tested sufficiently, there may be other issues with it.