Generating Multiple Rows from single row

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Generating Multiple Rows from single row

Post by baglasumit21 »

My source data is like

Col1, Col2, Col3, SQRNBR
A, B, C, 1|2|5|7|2
X, Y, Z, 1|2|3|7|4|9|1

I want the data in form

A,B,C,1
A,B,C,2
A,B,C,5
A,B,C,7
X,Y,Z,1
X,Y,Z,2
X,Y,Z,3
X,Y,Z,7
X,Y,Z,4
X,Y,Z,9

I need to generate the rows on the basis of seqnbr column where my values are seperated by | and the number of values that are pipe seperated will be the number of rows generated. Please help me to achieve either by Row Splitter or PIVOT or any other solution
SMB
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Use Pivot stage, It would give you what you want with the duplicates, do a search on the handling duplicates, I am sure you will find lots of good posts on handling duplicates.
Success consists of getting up just one more time than you fall.
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Post by baglasumit21 »

loveojha2 wrote:Use Pivot stage, It would give you what you want with the duplicates, do a search on the handling duplicates, I am sure you will find lots of good posts on handling duplicates.

i used pivot stage but my problem is values which are in col3 concatenated with pipe i dont the exact no of values ithere may be n no of values so in that case how can i use pivot stage?
SMB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Preprocess the pipe delimited column into separate columns before applying the Pivot stage. This is easily accomplished in a Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Post by baglasumit21 »

ray.wurlod wrote:Preprocess the pipe delimited column into separate columns before applying the Pivot stage. This is easily accomplished in a Transformer stage. ...
The only problem I have with this is that the column sqrnbr which is a pipe delimited has different number of values which are seperated with pipe. in some rows there are 5 values seperated, in some rows thr are 7, and in some case 10. its not fixed.
SMB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Who cares? Generate the maximum possible number of columns that you are likely to encounter. Say 24.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can also write a small routine to intake all the columns and depending upon the number of duplicate records to be created, generate the rows and send it back.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply