Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to generate random number (up to 7 digits) in Oracle?
Leon LI <leonfruit_at_yahoo.com> instructed their monkeys to type:
>Could you give me a hint on how to generate random
>numbers (up to 7 or 8 digits) in Oracle. The idea is
>to randomly select 100 account for creating
>a snapshot. The account number is up to 7 or 8 digits.
Oracle 8 has a random number generator package, DBMS_RANDOM
some pseudo code:
dbms_random.initialize (v_seed);
v_random := mod(abs(dbms_random.random),10000000);
v_random now contains a random number between 1 and 10000000 (providing v_seed seeds the generator satisfactorily)
Mark Styles
Oracle developer and DBA
http://www.lambic.co.uk/company
Received on Fri Aug 06 1999 - 09:54:49 CDT
![]() |
![]() |