CASE tatement

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

CASE tatement

Post 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
Thanx&Regards
scorpion
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply