Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: dbms_random question

Re: dbms_random question

From: Pavel Vetesnik <Pavel.Vet_at_volny.cz>
Date: Thu, 22 May 2003 16:54:03 +0200
Message-ID: <baioad$2hp3$1@ns.felk.cvut.cz>


Hi,

thank you for your posting, but I guess, you are wrong - otherwise I was extremly lucky and got ten times the same number. After calling the



dbms_random.initialize(5);
dbms_random.random;

I always got the 1034085445.

But it is all right now - the



dbms_random.initialize(TO_NUMBER(TO_CHAR(SYSDATE, 'SSSSS')));

cured the problem. But it is question why use the dbms_random package and not call the TO_NUMBER(TO_CHAR(SYSDATE, 'SSSSS')) directly. It gives "random-enough" numbers :-)

Pavel

"Jim Kennedy" <kennedy-down_with_spammers_at_attbi.com> píše v diskusním příspěvku news:_25za.695898$Zo.149563_at_sccrnsc03...
> Random does NOT mean without repeating. If you have a jar with 10 marbles
> and each marble has a different number on it. The random number generator
> is like choosing a marble and then putting the marble back in the jar and
> choosing again. This is called choosing with replacement. You can get
the
> same number again. If you are looking for a random number generator that
> draws a new marble each time and the does not replace the marble back into
> the jar then you are going to have to keep track of all the marbles drawn
> and ignore those that came up before.
> Jim
>
> --
> Replace part of the email address: kennedy-down_with_spammers_at_attbi.com
> with family. Remove the negative part, keep the minus sign. You can
figure
> it out.
> "Pavel Vetesnik" <Pavel.Vet_at_volny.cz> wrote in message
> news:baigpb$2e53$1_at_ns.felk.cvut.cz...
> > Hello,
> >
> > I want to generate a random number (to create an unique password). I
> > thought, the dbms_random package was created for this purpouse.
> >
> > I use such code:
> > ============================
> > nMagic NUMBER(11);
> >
> > dbms_random.initialize(5);
> > nMagic:=dbms_random.random;
> > dbms_random.terminate;
> > ============================
> >
> > But I always get the same number (1034085445 in this case)!
> > Giving different 'seed' parameter (5 above), I can get different
numbers,
> > but the same 'seed' means the same number.
> > So what that means? To create a random number I must pass a random
number
> to
> > the generator?!
> >
> > Please can you help me with this?
> > Thank you in advance,
> > Pavel
> >
> >
>
>
Received on Thu May 22 2003 - 09:54:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US