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: andrewst <member14183_at_dbforums.com>
Date: Thu, 22 May 2003 13:52:11 +0000
Message-ID: <2910937.1053611531@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.

--
Posted via http://dbforums.com
Received on Thu May 22 2003 - 08:52:11 CDT

Original text of this message

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