Hi,
We have a requirement to implement a recursive logic for example
Key ParentKey
1 2
2 3
4 1
5 4
3 6
1 is the record i have but i need to get parent and its grand parent and its great grang parent.like this i have to go till i don't find any record.
Can we implement the above logic using DS 8.7 . Please let me know
Regards,
Sandeep
Recursive logic using datastage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 36
- Joined: Fri May 21, 2010 12:40 am
- Location: Bangalore
Recursive logic using datastage
Sandeep Chandrashekar
Re: Recursive logic using datastage
If your source is from table, then better to do it there!
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Reply
create parameter pInitialValue to determine starting point for Key
Then sort the data in ascending order based on Key.
Then add transformer stage.
Create stage variables vkey and vparent.
vkey derivation :
if DSLink.Key = pInitialValue or DSLink.Key = parent then DSLink.Key else 0
vparent derivation :
DSLink.Parent
In the output put contraint : vkey <> 0
In the output columns put the stage variables vkey, vparent
This will work is the parent key is greater than the key for every record.
Then sort the data in ascending order based on Key.
Then add transformer stage.
Create stage variables vkey and vparent.
vkey derivation :
if DSLink.Key = pInitialValue or DSLink.Key = parent then DSLink.Key else 0
vparent derivation :
DSLink.Parent
In the output put contraint : vkey <> 0
In the output columns put the stage variables vkey, vparent
This will work is the parent key is greater than the key for every record.