Creating the sequence nbrs in a file.

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
vidya_6_2000
Participant
Posts: 10
Joined: Wed Apr 16, 2008 7:39 am
Location: USA

Creating the sequence nbrs in a file.

Post by vidya_6_2000 »

I have a special requirement. My file has the following columns.
A,B,C. with A being the main column. and file sorted by A.
I need to create an output file which has the following columns.
S,A,B,C. A, B and C are derived from the above I/P file columns and S is derived based on the following rule.
S = 01 for every unique value of A.
But if there are 2 records with the same value of A then S in incremented to 02,03 and so on, depending on how many records have the same value of A.
Here is an example of I/P file.
A B C
1 1b 1c
2 2b 2c
2 2d 2e
3 3b 3c
Here is an example of O/P file needed.
S A B C
01 1 1b 1c
01 2 2b 2c
02 2 2d 2e
01 3 3b 3c

Please do let me know how we could do this in DATASTAGE.

All help is greatly appreciated.

With Warm Regards,
Vidya Iyer
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Sort with a Sort stage and have it generate a key change column. In a downstream Transformer stage reset the counter to 1 if the key change column is 1, otherwise increment the counter.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Post by bikan »

I guess we also need to take care of partition...you may have to put hash partion of column A and then put same partion in transformer..or you can run transformer in sequential mode
Post Reply