Splitting a 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
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Splitting a Row

Post by ds2000 »

I have to split a row based on number of characters (e.g 2 characters in the following example) to multiple rows. Which stage i can use or what is the best technique to do it.

Input: (Act and Line columns are keys)

Act Line Desc
--- ----- --------------------
5 1 ABCDEFGH
8 1 LMNOP
9 1 XY


Desired Output:

Act Line Desc
--- ----- --------------------
5 1 AB
5 2 CD
5 3 EF
5 4 GH
8 1 LM
8 2 NO
8 3 P
9 1 XY
Last edited by ds2000 on Tue Aug 26, 2008 3:38 pm, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Transformer. Take advantage of the fact that, if properly prepared with intermixed record terminators, one 'record' can be written out by a Sequential File stage that reads back in as multiple records.

There's a FAQ posting on this very subject:

viewtopic.php?t=88639
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Investigate the Fold() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

Sorry its a parallel job i could'nt update the job type. Do i still need to continue here or create a new topic ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Continue here. I'm pretty sure you can edit the job type as I could swear people have done so in the past.

And here I even took the time to check your posting history and saw that all of the old questions were for Server jobs, so just figured we were just in the wrong forum. :(
-craig

"You can never have too many knives" -- Logan Nine Fingers
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

Thanks Chullet, i changed it to Px.

Source is db2 table and DESC column data is being used by other users who can update this column. So i can't split rows based on LF or any other delimiter.
I have to produce the output rows based on number of characters in DESC column. Output file is a source file for another system. See example.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can you parse the field into separate fields* using substring then use a Pivot stage?

* You will need enough of these to accommodate the longest possible input string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply