Re: Random Number in Developer/2000

From: <pberetta_at_my-deja.com>
Date: Mon, 06 Mar 2000 10:30:19 GMT
Message-ID: <8a01bs$fr6$1_at_nnrp1.deja.com>


Dante,
  There is no built-in, there is a DBMS_RANDOM package in Oracle8 that you might want to look into if you are running it. If you are using 7.3, the following may be of help. This was originally posted by Donald Atkinson, I've used it in several applications, it works well.

Create or Replace Package RAND is
Function RANDOM Return NUMBER;
pragma RESTRICT_REFERENCES(RANDOM, WNDS); End RAND;
/
Create or Replace Package Body RAND is
seed NUMBER;
reseed NUMBER;

--
Function RANDOM Return NUMBER is
Begin
reseed := NVL(reseed, 0) + 1;
If reseed = 123 or
seed is NULL Then
seed := NVL(seed, 0) + To_Number(
To_Char(SYSDATE, 'SSDDMIMMHH24'));
reseed := 0;
End If;
seed := To_Number(Replace(
To_Char(seed), '.'));
seed := seed * 1103515245 + 12345;
seed := To_Number('0.' || SubStr(Replace(
To_Char(Mod(seed/65536, 32768)), '.'), 3));
Return seed;
End RANDOM;
End RAND;
/
grant execute on RAND to public
/

Regards,
Paul


In article <01bf866f$8a13aba0$3408849e_at_default>,
  "Dante Tang" <c8354710_at_comp.polyu.edu.hk> wrote:

> In Oracle Developer/2000, is there any built-in can generate a random
> number? I have already search its help file for ran, random, etc. But
I
> found nothing about the random number...
>
> Thank you very much for your help and kind attention.
>
> Best wishes
> Dante Tang
>
> --
> e-mail : c8354710_at_comp.polyu.edu.hk
> URL : http://www.comp.polyu.edu.hk/~c8354710
>
Sent via Deja.com http://www.deja.com/ Before you buy.
Received on Mon Mar 06 2000 - 11:30:19 CET

Original text of this message