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: Ed Prochak <edprochak_at_adelphia.net>
Date: Thu, 22 May 2003 16:38:00 GMT
Message-ID: <3ECD0123.60900@adelphia.net>


Pavel Vetesnik wrote:
> 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
>

Based on your code sample, NO that is not the way to use random(). Why? Well, you are resetting the sequence everytime you call initialize(). The seed provides a way to start, and with a fixed value as you had in the original version, you always get the same first random number.

And you are using this to make a PASSWORD? You'll actually be better off using just the SYSDATE. Or make the user select some unique password.

-- 
Ed Prochak
running    http://www.faqs.org/faqs/running-faq/
netiquette http://www.psg.com/emily.html
--
"Two roads diverged in a wood and I
I took the one less travelled by
and that has made all the difference."
robert frost
Received on Thu May 22 2003 - 11:38:00 CDT

Original text of this message

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