Random number generation in buildop

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
Rajesh_kr82
Participant
Posts: 24
Joined: Sat Oct 15, 2005 1:09 pm

Random number generation in buildop

Post by Rajesh_kr82 »

I have to assign unique numbers to records in a buildop stage. How can i ensure that the numbers generated in all tha partitions are unique? Is there any way to get the partition number in C++ code i have written.

Rajesh
Regards,
Rajesh
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

Why do you need to assign it within the buildop? You could use a Surrogate Key Generator (or more generically, a Column Generator) to add a unique sequence number to the row.

There are quite a few posting out there for "Surrogate Key Generator" and "Column Generator" if that would suit your needs.

Brad.
Rajesh_kr82
Participant
Posts: 24
Joined: Sat Oct 15, 2005 1:09 pm

Post by Rajesh_kr82 »

Well here is the problem? lets say my data set is as below::

Key columns
1 ab
1 cb
1 cd
2 df
3 fd
4 fd
4 re

here i want to assign same number to all the 1's and 4's. The stages which you have mentioned will generate seperate number for all the different rows.
Regards,
Rajesh
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

System variable @PARTITION may do what you need. To be honest I'm not 100% clear on your requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

Both the Surrogate Key Generator and the Column Generator stages can add the partition number to your schema, which you could then use in your buildop.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You can assign numbers in the transformer stage using the FAQ on How do I set up a counter in a parallel transformer? You just need to sort and partition on that number field and only increment the parallel counter when the key number field changes. You can do this with a lastkey stage variable for comparison.
Rajesh_kr82
Participant
Posts: 24
Joined: Sat Oct 15, 2005 1:09 pm

Post by Rajesh_kr82 »

I got it done after setting the counter.

Thanks for help guys.

Rajesh
Regards,
Rajesh
Post Reply