4 Replies Latest reply: Apr 29, 2010 11:17 AM by rmurasse

# Can IF or SWITCH Statement be used inside a LOAD Statement?

Is it possible to use an IF or SWITCH Statement inside a LOAD Statement?

e.g.

Table2:

, IF Product = 'TRAKTOR' THEN 2 ELSE 1 END IF as Division

RESIDENT Table1;

How is the correct syntax to analyse the value of field A inside the LOAD statement, and create, depending on the content of value A, a new field B ?

Thanks for any help!

TB

• ###### Can IF or SWITCH Statement be used inside a LOAD Statement?

Yes !

You can use IF but IF is a FUNCTION not a statement as you think.

Use it like this :

IF (Product = 'TRAKTOR' ,2 ,1) as Division

Got it ?

As for SWITCH there is no such statement AFAIK. I use this kind of construction for that :

,IF(AGE <= 10,'* - INVALID DATE ' ,
IF(AGE > 10 AND AGE <= 19,'A - LESS THAN 20 YEARS',
IF(AGE > 19 AND AGE <= 25,'B - 20 TO 25 YEARS' ,
IF(AGE > 25 AND AGE <= 30,'C - 26 TO 30 YEARS' ,'D - ABOVE 30 YEARS')))) AS FAIXAET_DER_VSCAD

Sometimes I also like to use the PICK function :

Hope that helps !

• ###### Can IF or SWITCH Statement be used inside a LOAD Statement?

Yes, thats it. Thanks a lot.

TB

• ###### Can IF or SWITCH Statement be used inside a LOAD Statement?

Sorry, wrong post. This post may be deleted.

• ###### Can IF or SWITCH Statement be used inside a LOAD Statement?

You can use IF in this way:

if a=1 then