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:55:30 +0200
Message-ID: <baiod4$2hqv$1@ns.felk.cvut.cz>

"andrewst" <member14183_at_dbforums.com> píše v diskusním příspěvku news:2910937.1053611531_at_dbforums.com...
>
> Originally posted by Pavel Vetesnik
> > OK,
> > so I've changed the code to this:
> >
> > ============================
> > nMagic NUMBER(11);
> >
> > dbms_random.initialize(TO_NUMBER(TO_CHAR(SYSDATE, 'SSSSS')));
> > nMagic:=dbms_random.random;
> > dbms_random.terminate;
> > ============================
> >
> > Then the numbers seems to change. But my question is - is this
> > the correct
> > way, how the generator should be used?
> >
> > Pavel
> >
> >
> > "Pavel Vetesnik" píše v diskusním příspěvku
> > news:baigpb$2e53$1_at_ns.felk.cvut.cz"]news:baigpb$2e53$1_at_ns.felk.-
> > cvut.cz[/url]...
> > > 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

> If you have Oracle 8.1.6 or later, you don't need to call
> DBMS_RANDOM.INITIALIZE at all, so the problem of choosing a seed
> doesn't arise.

Thank you and I apologize I didn't provide the version number!

Pavel Received on Thu May 22 2003 - 09:55:30 CDT

Original text of this message

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