Skip to content

DBMS RANDOM

DBMS_RANDOM#

The DBMS_RANDOM packages enables creating arbitrarily numbers.

The following table explicates the procedures and functions that are comprised of the DBMS_RANDOM package.

Procedures/Functions Description
INITIALIZE Executes initialization of the DBMS_RANDOM package.
SEED Sets given values or a character string to seed.
STRING The STRING procedure creates arbitrary numbers.
VALUE Procedure creates arbitrary values within a specific range.
RANDOM Generates a random number

INITIALIZE#

The INITIALIZE is a procedure which initializes the DBMS_RANDOM package.

Syntax#

DBMS_RANDOM.INITIALIZE(val IN INTEGER);

Parameter#

Name In/Output Data Type Description
val IN INTEGER The value specified by seed.

Return Values#

Because it is a stored procedure, there is no return value.

Exception#

There is no exception.

SEED#

The SEED is a procedure creating values for arbitrary sequence by setting given values or a character string to seed.

Syntax#

DBMS_RANDOM.SEED(seedval IN INTEGER);
DBMS_RANDOM.SEED(seedval IN VARCHAR(2000));

Parameters#

Name In/Output Data Type Description
seedval IN INTEGER or VARCHAR(200 0) The character string or values that will be specified seed.

Return Values#

Because it is a stored procedure, there is no return value.

Exception#

There is no exception.

STRING#

The STRING procedure creates an arbitrary character string.

Syntax#

DBMS_RANDOM.STRING(opt IN CHAR, len IN NUMBER);

Parameter#

Name In/Output Data Type Description
opt IN CHAR The character string which will be created.
len IN NUMBER The length of the character string which will be created.

Description#

opt can specifies one of the following parameters listed as below.

  • 'u', 'U': Create arbitrary capital letters of alphabet.
  • 'l', 'L' : Create arbitrary small letters of alphabet.
  • 'a', 'A' :Create alphabet letters regardless of capital or small letters.
  • 'x', 'X' : Create capital letters of alphabet and numbers
  • 'p', 'P' : Create all the character strings that can be printable.

len(gth) indicates the length of an arbitrary character string and available input rages from 0 to 4000.

Return Value#

Because it is a stored procedure, there is no return value.

Exception#

There is no exception.

VALUE#

The VALUE is a procedure which creates arbitrary values within a specified range. If the range is not specified, arbitrary numbers from 0 to 1is returned.

Syntax#

NUMBER variable := DBMS_RANDOM.VALUE(low IN NUMBER, high IN NUMBER);

Parameters#

Name In/Output Data Type Description
low IN NUMBER The minimum value of the range for creating arbitrary values.
high IN NUMBER The maximum value of the range for creating arbitrary values.

Return Value#

Because it is a stored procedure, there is no return value.

Exception#

There is no exception.

RANDOM#

This function is a procedure for generating arbitrary integer values.

Syntax#

DBMS_RANDOM. RANDOM();

Parameter#

None

Return Value#

On successful execution, it returns a random integer value.

Exception#

There is no exception.

Example#

Output a random number.

iSQL> select dbms_random.random() from dual;