A Value Search in a String

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
sas
Charter Member
Charter Member
Posts: 13
Joined: Sun Mar 05, 2006 12:37 am

A Value Search in a String

Post by sas »

I have following 2 strings columns coming into the transformer -

String1 = "Qty1,Score1|Qty2,Score2|Qty3,Score3|.......|Qty20,Score20"
String2 = "Qty1,Score1|Qty2,Score2|Qty3,Score3|.......|Qty20,Score20"

I need to find out if there is a tie between Qty across these two String Columns i.e. any Qty is common in String1 and String2. E.g. If Qty2 of String1 is 30 - How would I find out whether this 30 is present in any of the String2 Qty out of those 20 String2 Qty. I am avoiding taking each Qty of String1 and compare String2 Qty. Looking for more efficient way to do in the same transformer.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Welcome Aboard ! :)

You can substring the incoming strings for Qty's and then use stage variables to be flagged according to your logic.


Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What are the scores doing in all of this? Is it the Qty values or the Score values being compared? Can you provide a couple of examples with numbers and a description of the expected outcomes, one where there is a match and one where there isn't? Are you prepared to countenance a solution that does not use a single Transformer stage and, if not, why not?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sas
Charter Member
Charter Member
Posts: 13
Joined: Sun Mar 05, 2006 12:37 am

Post by sas »

Ray - Thanks a lot for your attention. We do have these 80 columns in available (other process is calculating them). These String1 and String2 is formed in the Transformer based on the predefined categories in order to address different conditions. Examples of some conditions -
(1) Perform different set of activities if Category1/String1 has only one set (1 Qty and 1 Score) and Category2/String2 has also only one set and both the quantities are equal. Counting of | sign tells me how many sets are present instead of scanning all the different columns.
(2) Perform different activities if category1/String1 has only one set (1 Qty and 1 Score) and Category2/String2 has also only one set and both the quantities are NOT equal and Score of String1 is greater than Score of String2 (other way round of the score differece will make another condition)
(3) Perform different set of activities if category1/String1 has more than one sets and Category2/String2 has also more than one sets and "real qty" is matching in both categories. I am simply scanning "real qty" in String1 and String2 to get the answer.
(4) Perform different set of activities if category1/String1 has more than one sets and category2/String2 has also more than one sets and "real qty" is NOT matching in String2. (Match in String2 is another condition)
(5) Perform different set of activities if category1/String1 has more than one sets and Category2/String2 has also more than one sets and "real qty" is NOT matching in both categories and check if there is Qty tie between Qty String1 and Qty String2. This is condition where I am seeking your help and expert advise.

The reason to have the score after each qty because I have to pass the Score to other process of the selected qty.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's even more confusing! Please supply examples WITH NUMBERS as requested.

Does there exists a written specification for this logic? That is, some form of target-from-source mapping document?

Your terminology is also confusing. At one moment you are referring to a Transformer - at the next moment you are referring to an activity. The first belongs in a job, the second in a job sequence.

Which is it? On the basis of that answer, please clarify what you mean by the inappropriate term. For example are you using a Nested Condition activity in a job sequence (not a Transformer)? Or do you mean "separate processing stream" or "separate output link" when your context is a job?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

A picture ='s thousand words. Did i get that right, i think i did. So yes, as i was saying, give an an example of your sample data, and what should be the output for each and every condition.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Your second post is very confusing. What is 'Category' and 'real qty'? And how are you deciding the real qty from the first string? what will be the length of Qty field(eg. 20,30,30000)? Without the Sample data or prper information it will be impossible to speculate and suggest you something?

Sam
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

DSguru2B wrote:A picture ='s thousand words. Did i get that right, i think i did.
Well! If you are really looking for an answer. Then,

Code: Select all


i  <> I ,  Where 'I' refers to the nominative singular pronoun, used by a speaker in referring to himself or herself. .

:wink:
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

i = ?

Sam
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I_Server_Whale wrote: Well! If you are really looking for an answer. Then,

Code: Select all


i  <> I ,  Where 'I' refers to the nominative singular pronoun, used by a speaker in referring to himself or herself. .

:wink:
Cute. I was referring to the proverb :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply