Splitting a single record into multiple records

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
panchusrao2656
Charter Member
Charter Member
Posts: 64
Joined: Sat Sep 17, 2005 10:42 am

Splitting a single record into multiple records

Post by panchusrao2656 »

I have a record with five fieldss like
Column Names :A B C D E
Column Values :1 2 3 4 5

i want to convert it to 3 records with four fields as following:

Column Names : A B COL_NAME COL_VAL
Column Values : 1 2 C 3
Column Values : 1 2 D 4
Column Values : 1 2 E 5


I have 85(2+83) fields that needs to be converted to 83 records with 4 (2+2) fields.


I donot know how to get the third field using PIVOT, please share your ideas.

Thank You
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

do a search on "virtual pivot" may be this can help u
hi sam here
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

VERTICAL pivot would be an even better search. The Pivot stage will accomplish this task for you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hard code the column name next to each column using a transformer.
In PIVOT stage, mark A and B as key, and pass all hard coded column name into COL_NAME and the column value to COL_VAL.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: Generate a new column containing the column names (destined for COL_NAME) as a constant using a Cycle Generator with just one value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Provided the actual value is A,B,C,D...
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Doesn't matter what the actual values are. I'm sure A,B,C,D was just an example. You can hard code any string value such as

Code: Select all

"ItemNo,ItemClass,PkgType,PkgQty"
Unfortunately in this case it will require 83 comma-delimited fields. On the up side, it will only need to be constructed once. Copy/paste it to your Description field and to your target-from-source mapping documentation and you'll never need to type it again, unless the column names change in future.
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