Creating duplicate rows from input dataset

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
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Creating duplicate rows from input dataset

Post by ajith »

How to create duplicate rows from input dataset with respect to a condition

Hi All,

I have a Order start date (ORDER_ST_DT DATE) and an order completion date (ORDER_END_DT DATE). If the difference between start and completion date is greater than 5 then that record has to be duplicated that much times.

For eg, if the difference is 10 the same row has to be duplicated 10 times! Do we have any method in DataStage Parallel jobs to implement the same?


Thanks in Advance
Ajith
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

I am not sure if any stage can work like this.

But this can be done using a BuildOp.
As it is dynamic i.e. the total number of rows to be created, I think you might have to built a BuildOp in which you can create a loop and output rows as per this value of the diff between two cols.

Create a column which will store the diff between two dates. Pass this to Build op. In the BuildOp add a loop upto this diff col and output row in the loop.
Regards,
S. Kirtikumar.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Iam not with Datastage now, pls check if PadChar function can replicate string instead of just char. If so you can replicated the field concatinaed with a new line character.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Wow!!! that's a new learning.

But can this happen on the link? Because in PX, data might be treated as single row (due to virtual dataset), isn't it?
Writing this into a sequential file might result in a new line and multiple rows. But storing it in dataset may not help.
Regards,
S. Kirtikumar.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You might most easily be able to accomplish this in a shell script invoked from an External Filter stage. There does not have to be a one-to-one mapping between input and output row counts from this stage type.
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