Transformer constraints with multiple values?

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
PilotBaha
Premium Member
Premium Member
Posts: 202
Joined: Mon Jan 12, 2004 8:05 pm

Transformer constraints with multiple values?

Post by PilotBaha »

Is there a way to figure out if a field is equal to a value in a set using transformer constraints?

What I am trying to do is to avoid doing

Code: Select all

Link.Field = 1 or
Link.Field = 2 or 
Link.Field = 3 
but write something like

Code: Select all

Link.field in (1,2,3)
I couldn't find a way to do this in the constraints pull downs in the transformer..
Earthbound misfit I..
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

INDEX('123',Link.Field,1)
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

this won't work. He wants to see whether 1 or 2 or 3 is the value...

I don't know what PilotBaha is trying to achieve...;) want to save some time? or want to do a copy paste from SQL in DS transformer constraints?

Try CONVERT('123', '', Field) =''
Kandy
_________________
Try and Try again…You will succeed atlast!!
PilotBaha
Premium Member
Premium Member
Posts: 202
Joined: Mon Jan 12, 2004 8:05 pm

Post by PilotBaha »

The second poster is correct. Index won't work.. I am trying to avoid 10 different if statements with 9999 different indentations :)
Earthbound misfit I..
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

hunh? I just tried it. works great. What doesn't work about it? If 1 or 2 or 3 is in LINK.FIELD the result will be non-zero.
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

PilotBaha, Just to remind you... CONVERT works on one character at a time. So be cautious, if you want to check for anything more than 1 character.
Kandy
_________________
Try and Try again…You will succeed atlast!!
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

And yet Index will work on more then one character. Advantage -- Index!
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

INDEX will work. I have used list iterations like this one before and it works great.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

Boom! I think I originally got it from a DSGuruB post.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Sorry I'm late to this.

Index() WILL work, at least for single-character values in Link.Field1.

Further, it will be more efficient than any of the other methods postulated.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

I've used it for two digit codes. The trick was inserting a character that wouldn't appear in the field like this;
INDEX('12|23|45|XY',LINK.FIELD,1). You'll get a non-zero return for 12, 23, 45, and XY codes. You can go bigger I'm sure, you just have to make sure that a field doesn't show up as a subset of one of the other choices within the "delimiter".
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You may need to be careful of data types in parallel jobs. Otherwise Index() is the best tool for the job specified in the original request.
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