many records to one

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
DSbox61
Premium Member
Premium Member
Posts: 62
Joined: Mon May 22, 2006 10:18 am

many records to one

Post by DSbox61 »

Hi ppl,

I have a job where i have 3 records coming from DB2(1)
C1|A1
C1|A2
C2|B1
and 2 records coming from DB2(2)
C1|X1
C2|X2
In the output file i want
C1|A1A2|X1
C2|B1|X2

DB2(1)==>Transformer==>Flat File
^
||
||
DB2(2)

thnxxx...
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

First you need to perform vertical pivoting on each input. Once you have that done. Then store one input into a hashed file. Let the other be the input. Do a lookup on your first column and then concatenate the records together with a pipe in between.
Search the forum for vertical pivoting.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, you'll need to build a single record from the multiple incoming records yourself via concatenation in stage variables. As noted, you can search the forum for many discussions on the subject of a 'vertical pivot' which is what that would be called when you do rows to columns.

Columns to rows is called a 'horizontal pivot' and there's a stage available to accomplish that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSbox61
Premium Member
Premium Member
Posts: 62
Joined: Mon May 22, 2006 10:18 am

Post by DSbox61 »

But we cannot achieve vertical pivot through pivot stage in server edition rifght!
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Right.
Also, there is no built in stage for doing a vertical pivot.
You can achieve it, using alternative methods which is discussed many times in this forum
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Search my friend search. Its not that hard...
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Especially this one which is a perfect solution to your problem.

viewtopic.php?t=97681&highlight=vertical+pivot

Sam
DSbox61
Premium Member
Premium Member
Posts: 62
Joined: Mon May 22, 2006 10:18 am

Post by DSbox61 »

yes sam, even i implemented the same u mentioned.....it really is the perfect solution......thnx 2 all gurus...and thnx to jim. :D
Post Reply