Page 1 of 1

CASE tatement

Posted: Thu Oct 12, 2006 6:16 am
by scorpion
hi all,

how can i implement CASE Logic in datastage..

for ex: CASE when 'tan' then 'tango' when 'asc' then 'ascential'...like that

i hope it will wrks using 'if then else',but thinking to use CASE..


thanks in advance

Posted: Thu Oct 12, 2006 6:21 am
by DSguru2B
You can use case statements in basic routines. No case statements in the transformer, but you can achieve the same using if then else.

Posted: Thu Oct 12, 2006 6:33 am
by ArndW
The CASE statement is used in multi-line programs while the IF-THEN-ELSE can be done on a single line (i.e. in a stage variable or derivation).

The CASE in a BASIC program looks like

Code: Select all

   BEGIN CASE
      CASE I=AmTired 
         Ans = 'Goto Sleep'
      CASE Today='Tuesday'
         Ans = 'Only 3 days left to the weekend'
      CASE 1
         Ans = 'This is the catchall'
   END CASE

Posted: Thu Oct 12, 2006 1:41 pm
by ray.wurlod
Most databases allow CASE constructs in SELECT statements. You can put the entire construct in the Derivation field in the Columns grid (rather than use user-defined SQL).

Code: Select all

CASE WHEN PROD_CODE = 'tan' THEN 'tango' WHEN PROD_CODE = 'asc' THEN 'Ascential' ELSE 'unknown' END AS PRODUCT