How to generate multiple rows?

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
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

How to generate multiple rows?

Post by anu123 »

Helo every one.

I have a scenario as below...

input(a FILE):

col1 col2 col3
---------------------
100 aa1 bb1
200 aa2 bb2

Output needed as (also a FILE)

col1 col2 col3 col4 col5
----------------------------
100 aa1 bb1 xx1 yy1
100 aa1 bb1 xx2 yy2
100 aa1 bb1 xx3 yy3
200 aa2 bb2 xx1 yy1
200 aa2 bb2 xx2 yy2
200 aa2 bb2 xx3 yy3

Any ideas how this can be accomplished...?

thanks in advance.
Thank you,
Anu
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Sort the data, use Stage variables to track group changes and reset the numbering sequences.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

How are you getting xx1 and yy1. How do you know you need to make 3 copies of each row. If that remains static, feed the input file the transformer with three output links, add two columns, duplicate the first three columns, add appropriate value for fourth and fifth column in the three links. Concatenate the files together.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Thank you all for your time.

each row may be needed to copy more than thrice depending on case.But based on the case 'Number of Copies' I need to make is static(i.e 3/10/50..).

If its '3', having 3 streams to feed 3 transformers sounds good. But if its '50', we probably may need better approach.

'xx1' and 'yy1' are sample values i took. But really they look some thing different.So I can not go for incrementing a number.But these values are static even in case of '50' copies..


thanks again...
DSguru2B wrote:How are you getting xx1 and yy1. How do you know you need to make 3 copies of each row. If that remains static, feed the input file the transformer with three output links, add two columns, duplicate the first three columns, add appropriate value for fourth and fifth column in the three links. Concatenate the files together.
Thank you,
Anu
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Anu,
Again where you get these case from? Perhaps you havent mentioned here.
There are several other ways of acheiving this. viewtopic.php?t=88639 You can create a parallel routine as well.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
dsisbank
Premium Member
Premium Member
Posts: 50
Joined: Fri Aug 11, 2006 4:53 am

Post by dsisbank »

sort data using col1 ,and set true Create Key Change Column property.DS adds one more column Keychange().Use transformer stage variables (IF Keychange()=1 THEN 1 ELSE variable+1 ),concanacate xx
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Need actual sample data with explanation of how each case is derived.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

source :

100 DAVE YAHOO
200 ANN MS
300 SCOTT ORACLE

output

100 DAVE YAHOO 1 CHRONIC
100 DAVE YAHOO 2 HELTHY
100 DAVE YAHOO 3 CORDIAC
200 ANN MS 1 CHRONIC
200 ANN MS 2 HELTHY
200 ANN MS 3 CORDIAC
300 SCOTT ORACLE 1 CHRONIC
300 SCOTT ORACLE 2 HELTHY
300 SCOTT ORACLE 3 CORDIAC

in this case below are static.

1 CHRONIC
2 HELTHY
3 CORDIAC
I need to make 3 copies of each incoming row.

thanks


DSguru2B wrote:Need actual sample data with explanation of how each case is derived.
Thank you,
Anu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Me, I'd create a table with the three values in my database of choice, load the input file into another and then extract from that database letting the sql do a cartesian product. :wink:
-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 »

Or a Lookup from a three row table, allowing multiple row return. Create a Lookup File Set with "X" as the key for all three columns (you will need to set "allow duplicates" to true). Then lookup against the key value "X", with the drop down list allowing multiple row returns from that reference link. Use Entire partitioning for the Lookup File Set.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or that. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Thank you every one for your valuable time and suggessions.I will update you all once I am done with that.

thanks again..
chulett wrote:Or that. :lol:
Thank you,
Anu
Post Reply