Parameters for IF condition

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Parameters for IF condition

Post by vinaymanchinila »

Hi,
I have a scenario where incoming column value needs to be compared, ex
If Src.Col1=A then 01
If Src.Col1=B then 02
.
.
If Src.Col1=F then 07

How can I parameterize it in a situation when the values of Col1 are dynamic.

Thanks,
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

There are too many ways to do this to answer, at least given the information in the request. If your column length is always 1 and starts with "A" you could index with a simple SEQ(In.Col)-64 to get a number. If you column is of variable length then this method won't work, but if all columns are of equal length you could use the INDEX() function to locate a substring text and return a position (which you can divide by the length to get a numeric series of answers without holes)
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi Andrw,

The column lenght is not always the same, its varchar(3), I dont get it when you say all columns, I am asking about just one column, which has multiple values and if there is a new value added in the source (like AAW) then I want to avoid changing the if statement in the job.
Thanks,
Vinay
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not just do something with a Lookup? Build a table with the subsitution values and use that. When values change or are added, no change to the job itself would be needed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi Craig,

Sounds good, one of our senoir developers also had an idea of using an external stage to read the column in and use parameters for values.

Looking at the options that are available.
Thanks,
Vinay
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Check out lookup_int16_from_string() in the Modify stage for small tables, or contemplate using a Lookup stage.
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