Page 1 of 1

when lookup returns multiple rows - accomidate in same row

Posted: Fri Jun 22, 2007 7:38 am
by muascdev
my requirement is as follows, i have an input file, and on one of the fields , i need to do a look up, which will return 3 rows always, with 1 column ineach row, now i need to add these 3 vaules from 3 rows into an output file into 3 diff column on the same row. we are using lookup stage in parallel, but dont know how to proceed further.

ex : input file
123,234,2345
look up on 234 returns 12
13
14
output should be:
123,234,2345,12,13,14

appreciate any help

Posted: Fri Jun 22, 2007 7:54 am
by DSguru2B
Get the three rows, pass it through a transformer where you need to utilize stage variables to do this vertical pivoting.
Something to the effect of, compare present key with previous rows key, if same, concatenate the row values with each other. Pass it through remove duplicate stage and retain the last record which will have all the three values.
For more info on the method, search on "vertical pivot"

Posted: Fri Jun 22, 2007 8:19 am
by chulett
Could you not also do the pivot in the source query that builds the lookup? Especially if you know it will 'always be three', return a single record there with the three fields rather than all the shenanigans to do it afterwards.