Skip Headers
Oracle® OLAP DML Reference
10g Release 2 (10.2)

Part Number B14346-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

RANDOM.SEED.1 and RANDOM.SEED.2

The RANDOM.SEED.1 and RANDOM.SEED.2 options specify values used by RANDOM when computing random numbers. To compute the number, RANDOM uses the values of the options RANDOM.SEED.1 and RANDOM.SEED.2, and then changes the values for the next time.

When you want to reproduce the same sequence of random numbers when you are developing and debugging your application programs set RANDOM.SEED.1 and RANDOM.SEED.2 to some specific values just before using RANDOM.

Data type

INTEGER

Syntax

RANDOM.SEED.1|RANDOM.SEED.2 = n

Arguments

n

An INTEGER expression that specifies the value to use when generating random numbers. The default is for RANDOM.SEED.1 is 12345 and RANDOM.SEED.2 is 1073.

Notes

Reproducing a Random Sequence

As illustrated in Example 22-1, "Producing Random Numbers", when you want to reproduce the same sequence of random numbers when you are developing and debugging your application programs, set RANDOM.SEED.1 and RANDOM.SEED.2 to some specific values just before using RANDOM. To duplicate the sequence, set these options to the same values just before using RANDOM again. Then changes in the behavior of your programs will be caused by your changes to the programs and not by differing sequences of random numbers.

Examples

Example 22-2 Explicitly Seeding RANDOM for a Test

Assume that you have the following dimension and variable in your analytic workspace

DEFINE id DIMENSION TEXT
DEFINE myvar VARIABLE INTEGER <id>
 

As shown in the following code, when you use RANDOM to populate myvar without seeding it first. Oracle OLAP populates myvar with different values each time the RANDOM executes.

myvar = 0
myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     11
a2                     19
a3                     14
 
myvar = 0
myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     16
a2                     13
a3                     12
 

Now, assume that you want to write a test that uses RANDOM to create predictable values for myvar. As the following code illustrates, to ensure that the results of RANDOM are the same from time to time, you must set the values of RANDOM.SEED.1 and RANDOM.SEED.2 right before the execution of RANDOM.

myvar = 0
RANDOM.SEED.1 = 5
RANDOM.SEED.2 = 3
        myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     10
a2                     16
a3                     13
 
myvar = 0
RANDOM.SEED.1 = 5
RANDOM.SEED.2 = 3
myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     10
a2                     16
a3                     13

The values that you set for RANDOM.SEED.1 and RANDOM.SEED.2 do not stay the same throughout a session. As the following code illustrates, when you do not reseed with the same values before each execution, the values produced by RANDOM are not the same.

myvar = 0RANDOM.SEED.1 = 5
RANDOM.SEED.2 = 3
myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     10
a2                     16
a3                     13

myvar = 0
        myvar = RANDOM (10, 20)
REPORT myvar
 
ID               MYVAR
-------------- ----------
a1                     11
a2                     16
a3                     20