Hello,
I have a requirement where my source is oracle table and one of the column containes value separated by commas. I want to create individual record for these values. For example
Input
------
Colum1| Column 2
123456| 2,5,6,100,45,51
Output
--------
Colum1| Column 2
123456|2
123456|5
123456|6
123456|100
123456|45
123456|51
I know with transformer loop option, I can create multiple rows from single row, but no idea how I can get individual value in column2 for each record. I think it might have worked with a pivot stage if the maximum number of comma in second column is known. But I unfortunately the comma in Column2 is no upper cutoff, In other words I do not have a clue on the number of values in column2.
Really sorry if It is a repeat question, I cannot find answer when I searched. Please share the link if this is already discussed
Any help is greatly appreciated !!
Column with not fixed number of delimited values
Moderators: chulett, rschirm, roy
Column with not fixed number of delimited values
Thanks,
Sham
Sham
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
No, do use a loop. There are examples documented. Create a stage variable containing the number of delimited fields (use DCount() function, for example). Loop exit condition is Within the loop, extract an individual field using For example, Field(in.Column2, ",", @ITERATION, 1)
Load this into a loop variable and use that to provide the value of the output field. The second example in this IBM Knowledge Center article will provide a similar explanation.
Code: Select all
@ITERATION <= svNumberOfFields
Code: Select all
Field(in.Column, delimiter, @ITERATION, 1)
Load this into a loop variable and use that to provide the value of the output field. The second example in this IBM Knowledge Center article will provide a similar explanation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Any expression.
For example a constant 10 if you always have 10 delimited fields.
But @ITERATION is there, and singularly useful.
Other techniques would be appropriate in the "filling in the gaps in a sequence of dates/numbers" scenarios.
For example a constant 10 if you always have 10 delimited fields.
But @ITERATION is there, and singularly useful.
Other techniques would be appropriate in the "filling in the gaps in a sequence of dates/numbers" scenarios.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.