Recursive lookups

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
atulgoel
Participant
Posts: 84
Joined: Tue Feb 03, 2009 1:09 am
Location: Bangalore, India

Recursive lookups

Post by atulgoel »

Hi,

I have a data like;

100:200
200:300
300:400
500:600
600:700
900:1000
1000:1100

Input data shows that 200 is linked to 100, 300 is linked to 200 and also 200 is linked to 100 so 300 is linked to 100. similarly, 400 is also linked to 100 because 300 is linked to 200 and 200 is linked to 100.

And the required output is:

200:100
300:100
400:100
600:500
700:500
1000:900
1100:900

Can i use recursive lookup to achieve this and if yes, then how?


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

Post by ArndW »

DataStage does not have a capacity for recursive lookups the way you explained. It is possible to have several consecutive lookups to the same source located after each other in order to emulate this functionality but you would need to put sufficient lookups to guarantee that you would find the "root".

Depending upon where your source data is stored (i.e. in a database), you might be able to resolve the lookups using an appropriate SQL query.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Is that only the structure you need or do you have more attributes to work with?

You can do that by running through the data 2 times.

First time you can load the data - as it is - into a table.

Second time you can use it as a lookup with flattened data (using something like level of Oracle) to locate the root node.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Why not define Reference Table for all Combinations.

Key Value

200 100
300 100
400 100
600 500
700 500
1000 900
1100 900

Field(InputData,':',2)--Output of this to be used to Lookup in Reference Table(Key Column).
Regards
LakNar
algfr
Participant
Posts: 106
Joined: Fri Sep 09, 2005 7:42 am

Post by algfr »

Where does the data come from ?

If you want a powerful solution and you're using a DB, I strongly recommend to create a stored procedure function that will handle any possible depth.

From there call the stored procedure in a SQL statement in Datastage.

Also, this is the most efficient method to me.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Hi

Store this in a Oracle table and you can use the CONNECT BY clause to
get this recursive work

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

Post by DSguru2B »

Or in DB2 use WITH command. Lookup the syntax on google.
A single sql query would suffice, no need for a sql stored proc.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or in UniVerse use WITHIN. (But this is messy from parallel jobs.)
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