Page 1 of 1
FOR / DO Looping in transformer
Posted: Tue May 25, 2010 10:31 am
by agpt
How do we implement FOR or DO looping in transformer?
Posted: Tue May 25, 2010 10:55 am
by priyadarshikunal
First let IBM release the next version of datastage
![Wink :wink:](./images/smilies/icon_wink.gif)
and then you will be able to use looping variables. Till then use workarounds including parallel routines.
Posted: Tue May 25, 2010 11:03 am
by agpt
Thats what exactly I am looking for.... with which work around I can implement it
Posted: Tue May 25, 2010 12:04 pm
by chulett
How about you first explain to us why you think you need to do "looping" in a transformer? Perhaps there is another way to accomplish whatever it is that you need to do.
Posted: Wed May 26, 2010 12:02 am
by agpt
I have data like:
ID Flag
1 Y
1 N
1 Y
2 Y
2 Y
2 N
2 N
3 N
3 Y
The output I want is:
ID Flag
1 Y
2 Y
3 Y
That is across each id it would check for flag and if this is 'Y' against any occurence, It would give Y a final output with one occurence of ID.
Posted: Wed May 26, 2010 12:11 am
by truenorth
If I interpret your logic correctly that you want one occurrence of Y's, then use the constraint Flag = 'Y' in Transformer together with either a Sort (no dups) or Dedupe.
Posted: Wed May 26, 2010 2:17 am
by Sainath.Srinivasan
Or aggregate by ID and Max(flag)
Posted: Wed May 26, 2010 4:06 am
by ray.wurlod
Or stage variable to detect whether 'Y' has been encountered, and either stage variables or Key Change column from Sort stage to detect change of key.
Posted: Wed May 26, 2010 6:17 am
by chulett
Trivial in a Server job as well. No looping required.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Wed May 26, 2010 10:18 am
by agpt
hmm
Thanks to all.