Re: PL-SQL Random Number Generator?

From: <nasof_at_hotmail.com>
Date: 1998/08/15
Message-ID: <6r2tpr$n6v$1_at_nnrp1.dejanews.com>#1/1


[Quoted] Im sorry to butt in, BUT... I took exception with the reason that you cannot use a sequence is because it will wrap around at some point, but a random number wont.

I understand the need for a random number (as long as you dont care about duplicates), but in Oracle a sequence can go as high as: 99,999,999,999,999,999,999,999,999,999,999,999,999 (type NUMBER(38)) THEN it will repeat. DAMN Thats a big number! If you started today and inserted a million rows a second (starting with a sequence number of 1) I bet it would take a loooooong time before it repeats! (any one care to figure this out?)

Besides, thats the same range of values you could put on your Random number, I dont know how you can say that "At least with a some random number generators, the size of that sequence will be large and unlikely to repeat" Most random number do repeat, whereas sequences don't (unless you specify CYCLE).

Just out of curiosity, how do you _prove_ randomness?

To jcann: Can you email me the SQL to create one of "ORACLE's random assignment" from a sequence.

-Frank

In article <35D492ED.36F6E7E3_at_fairway.com>,   jcann_at_fairway.com wrote:
> Todd Weaver wrote:
> >
> > this may be a pissant question, but why not use a sequence, and simply use
> > ORACLE's random assignment from that sequence? Assign the sequence no
> > maximum number, and don't choose the numbers in order..... I suppose this
> > may be limiting, as far as security, or where you can access the number
> > from, but for simply purposes, is this not a viable alternative?
>
> Because I am implementing a system where results must be assigned
> randomly. Although one can argue that a computer "can never generate a
> random number", several random number algorithms have proven to be ~99%
> random.
> I think your suggestion about using a sequence is a good idea but will
> not work for this situation. Why? Because a sequence will repeat at
> some point. At least with a some random number generators, the size of
> that sequence will be large and unlikely to repeat:
>
> from Kevin Taufner's UTIL.PKG:
> (posted to archives section of http://www.revealnet.com/pipeline.htm)
>
> || Purpose: Modifies the method used to calculate a random value
 within the
> || package function RAND. A value of [1] uses the
 Multiplicative
> || Congruential method (which produces about 2.57E8 results)
 and a
> || value of [2] utilizes a Rectangularly Distributed
 Statistical
> || method which results in about 6.95E12 values.
>
> Thanks
>
> > -Veeb
> >
> > Hakan wrote in message <35D2645D.6F0586C1_at_ibm.net>...
> > >Hi,
> > >
> > >The following source code belongs to Oracle Guru, Mr.Thomas Kyte. It was
 not
> > >difficult to find since I use it.
> > >
>
> --
> Jeffery Cann
> Fairway Systems, Inc.
> Senior Software Engineer
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Sat Aug 15 1998 - 00:00:00 CEST

Original text of this message