Skip to content
January 21, 2011 / doganay

PRODUCING RANDOM NUMBERS

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Hi,

You may want to produce random numbers. Well, you may use dbms_random.random for that.
But in 10g PL/SQL reference iy says:
“This procedure is obsolete and, although it is currently supported, it should not be used.”

RANDOM Procedure
This procedure generates a random number (but see Usage Notes).
Syntax
DBMS_RANDOM.RANDOM
RETURN binary_integer;

Usage Notes
This procedure is obsolete and, although it is currently supported, it should not be used.

Instead, you can use:

DBMS_RANDOM.VALUE(
low IN NUMBER,
high IN NUMBER)
RETURN NUMBER;

for example:

select DBMS_RANDOM.VALUE(10,99) from dual;

–this will produce a number 10 to 99
you can round it, etc..

select round(DBMS_RANDOM.VALUE(10,99)) from dual;

try and pray 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: