how can we split into multiple records

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
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

how can we split into multiple records

Post by tostay2003 »

Hi all,

need a bit of help with splitting into multiple records.

i have 7 columns as shown below (ps there are more than 7 columns in the table)

id,sales_typ1,sales_amt1,sales_typ2,sales_amt2, sales_typ3,sales_amt3.

I want to split into three records as below

id,sales_typ1,sales_amt1,
id, sales_typ2,sales_amt2,
id, sales_typ3,sales_amt3.

How can I do this in datastage?

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

Post by DSguru2B »

if your target meta data remains the same (3 columns) then you can split it in a tranformer and then collect it later on
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
dwandbi
Participant
Posts: 29
Joined: Sat Feb 04, 2006 6:17 pm

Try using

Post by dwandbi »

Pivot stage and split the whole column into 3 cols

I never tried. Let me know if it gets results

thanks,
Tom
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

Post by tostay2003 »

sorry posted a bit wrong

its actually

id, sales_typ1_amnt, sales_type2_amt, sales_type3_amt

and need it like

id, sales_typ1_amnt,
id sales_type2_amt,
id sales_type3_amt
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

i have never used the pivot stage, so dont know weather it can be achieved via pivot stage.
A simpler solution is as i suggested, provied the target meta data remains identical,
pass your file through the transformer, have three links coming out of it
pass id to all three, and the second column to the first link, the third column to the second link and the last column to the third link. Collect it via link collector. Your final target, collected file will have the result you desire.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If you have the option to use Enterprise Edition, then I would recommed you to use that and use the plug-in stage known as the PIVOT STAGE.
This stage will result in a definite solution to your problem.
Where as in the server this can be done through a transformer as mentioned above.
The limitation would be that your positions for the pivot should be static.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

Use the database Luke. Do something as follows in a DB stage:

Code: Select all

select ID, sales_typ1_amnt
from yourtable
union
select ID, sales_typ2_amnt
from yourtable
union
select ID, sales_typ3_amnt
from yourtable
Ogmios
In theory there's no difference between theory and practice. In practice there is.
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

Moreover :D ... if you want to keep the amnt's in order, something as:

Code: Select all

select ID, sales_typ1_amnt, '1' as order
from yourtable
union
select ID, sales_typ2_amnt, '2' as order
from yourtable
union
select ID, sales_typ3_amnt, '3' as order
from yourtable
order by ID, order
Ogmios
In theory there's no difference between theory and practice. In practice there is.
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

Post by tostay2003 »

I need to convert from flat file, so guess i need to try what DSguru2B says. I will let you all know tomorrow after giving it a try
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

3 output links from a transformer, use a link collector, turn on Inter-Process row buffering.
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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is a server Pivot stage, and this is exactly the task that it is intended to perform. Use the Pivot stage.
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