Page 2 of 2

Posted: Tue Apr 12, 2011 4:55 pm
by ray.wurlod
Use Mod() function with Random() function. For example Mod(Random(),100) will return a number between 0 and 99. For a 10% random sample, use Mod(Random(),100) < 10 in a constraint expression. The constraint expression could also include a restriction on @OUTROWNUM.

Posted: Tue Apr 12, 2011 7:19 pm
by jwiles
Krishna, since you require an equal number of records per key value to be selected, how is that number determined? Is it arbitrarily chosen at runtime or does it need to be calculated somehow? If calculated, what is the calculation?

Regards,

Posted: Tue Apr 12, 2011 7:28 pm
by krishna14
It has to be chosen arbitrarily at runtime....

Posted: Tue Apr 12, 2011 8:20 pm
by ray.wurlod
Job parameter seems to be indicated then. For example:

Code: Select all

Mod(Random(),100) < 10 And @OUTROWNUM <= #jpMaxRowsPerNode#

Posted: Tue Apr 12, 2011 8:58 pm
by jwiles
I think Ray and I need "Dueling Banjos" playing in the background :wink:

Posted: Tue Apr 12, 2011 9:19 pm
by krishna14
Thanks Ray & jwiles ,

the job parameter given by Ray is working fine for me .Thanks for your help ...

Posted: Tue Apr 12, 2011 9:27 pm
by jwiles
Good! I was about to ask which of us was solving the right problem... :)

Regards,

Posted: Tue Apr 12, 2011 9:44 pm
by krishna14
Thanks for your Support jwiles & Ray .

I really appreciate your help ...

Posted: Wed Apr 13, 2011 9:06 am
by krishna14
I have a Question ,does RANDOM means every time if we run the Same I/P file should i be able to get different RANDOM records ...?Please clarify me..

Posted: Wed Apr 13, 2011 4:33 pm
by ray.wurlod
Since computers can only ever do pseudo-random, the answer depends totally on whether or not you use the same seed for the random number generator each time, or whether you use a different seed. A seed based on current date and time is fairly "random".

Posted: Thu Apr 14, 2011 9:43 pm
by krishna14
According to my requirment i have to generate different random records for every run by using the same input DB2 file...

how can i work it out ..Please help me out .

Posted: Thu Apr 14, 2011 11:02 pm
by ray.wurlod
Have you bothered to read the Parallel Job Developer's Guide section on the Random() function yet?

Posted: Fri Apr 15, 2011 11:56 am
by jwiles
Krishna,

Since you've marked this as resolved, would you share what your final solution was?

I was going to suggest using a column generator to gain access to the seed option with it's random generation. That can be parameterized as well. I think it's possible also within DB2.

Regards,

Posted: Wed Apr 20, 2011 9:16 am
by krishna14
jwiles,

I apoloize for delayed reply,i used the column generator and used the seed property as suggested ...i'm able to get the desired ouput .

i have a question ..if i use the RND () or RANDOM () function how can i seed system time to it so that i can get random numbers for every run...?

Posted: Wed Apr 20, 2011 9:27 am
by jwiles
There's not a method to do so within the transformer stage interface in Designer. You would need to write the logic in a transform outside of the Designer GUI (in Unix) to use the native Transform operator language and functions, which I believe includes seed functions for rand() and random().

I think how you've done it is sufficient to meet your needs and is easily supportable by others in the future.

Regards,