All Forums General
AMIT_TERSE 17 posts Joined 08/13
14 Nov 2014
BTEQ .IF ERRORCODE <> 0 THEN <QUERY>

Hi,
 
I have a scenario where I need to writed a query if the ERRORCODE condition satisfies in BTEQ .the Query is quite large and have many Joins , so is there any way I can put it to next line, since when I put the next line it doesn't work.
Workaround for the same would be helpful but need to have it after then.
Thanks in advance.
 

Regards, Amit Terse
Raja_KT 1246 posts Joined 07/09
14 Nov 2014

I m not able to understand it properly. It looks like you just want to copy and paste the code. Try to put in a viewable way and press enter or in some unix env , you need to put front slash \, say like in unix script:

for script in abc_DropViews.sql \

def_DropIndexes.sql \

ghi_DropTables.sql \

jkl_DropDatabases.sql \

mno_DropRoles.sql \

pqr_DropProfiles.sql

do

.....

 

if you want to work with error label, then you can refer to this link:

 

http://forums.teradata.com/forum/analytics/error-code-3807-not-working-even-if-label

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

dnoeth 4628 posts Joined 11/04
15 Nov 2014

Hi Amit,
you might either omit the period in front of IF or utilize GOTO/LABEL:

.IF ERRORCODE = 0 THEN .GOTO skipit
<query>;  
.LABEL skipit;

IF ERRORCODE <> 0 THEN 
<query>;

 

Dieter

AMIT_TERSE 17 posts Joined 08/13
19 Nov 2014

HI Diter,

IF ERRORCODE <> 0 THEN

<query>;

 

The above solution which I was looking for worked fine but it gave the warning as shown below.

 

For eg:

 

IF ACTIVITYCOUNT = 2 THEN

SELECT *  user_30_day_tables.test1

WHERE 1=1;

 *** Warning: Expected a '.' before the command.

 

Any comments on this?

 

 

 

Regards,
Amit Terse

Liji.Anooj 1 post Joined 08/16
22 Aug 2016

Hi Amit,
BTEQ commands must be preceded by a period '.'
so use .IF in your BTEQ.So query must be
.IF ACTIVITYCOUNT=2 THEN
<QUERY >
 
 

You must sign in to leave a comment.