Duplicate records based on col's data

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
tbtcust
Premium Member
Premium Member
Posts: 230
Joined: Tue Mar 04, 2008 9:07 am

Duplicate records based on col's data

Post by tbtcust »

Hello All,

I have a task to duplicate/repeat records in a file based on a particular column. All columns are separated by "|". This particular column has codes that are separated by commas.

As an example, if there are three codes on one record, that record should be outputted three times, with the code in the first position. See below. Thanks in advance for any help.

Example
Input record
Field1 | Field2 | Field3 | 9, 8, 7

Output Records
9 | Field1 | Field2 | Field3
8 | Field1 | Field2 | Field3
7 | Field1 | Field2 | Field3
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

What specific release of DataStage 8 are you on? If you are on 8.7 or later I believe this can be done with a transformer loop. On any release of 8 you can use the Pivot stage to do a horizontal pivot. Look it up in the Parallel Job Developer's Guide, the example there is almost exactly what you are doing.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
tbtcust
Premium Member
Premium Member
Posts: 230
Joined: Tue Mar 04, 2008 9:07 am

Post by tbtcust »

Thank you for the reply and suggestion asorrell.

I looked at the Transform Loop and Pivot Stage. They both seem to rely on the codes being in separate columns. This is not the case for me. I need to duplicate a record based on the content of one column where the content of that one column is separated by commas. So

the input record looks like this
Field1 | Field2 | Field3 | 9, 8, 7


Output Records will be:
9 | Field1 | Field2 | Field3
8 | Field1 | Field2 | Field3
7 | Field1 | Field2 | Field3
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The Pivot stage does require separate columns but Transformer Looping has no such requirement.
-craig

"You can never have too many knives" -- Logan Nine Fingers
tbtcust
Premium Member
Premium Member
Posts: 230
Joined: Tue Mar 04, 2008 9:07 am

Post by tbtcust »

Thank you chulett. I was relying on the documentation example way too much.

I have coded the transformation loop and it works fine.

Thanks again.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply