General
Enthusiast

## 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.

Tags (2)
4 REPLIES
Enthusiast

## Re: BTEQ .IF ERRORCODE <> 0 THEN <QUERY>

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:

Junior Contributor

## Re: BTEQ .IF ERRORCODE <> 0 THEN <QUERY>

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>;`
Enthusiast

## Re: BTEQ .IF ERRORCODE <> 0 THEN <QUERY>

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.

Visitor

## Re: BTEQ .IF ERRORCODE <> 0 THEN <QUERY>

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 >