What are the requirements and steps to set up a database to use DBMS_RANDOM functions?
The DBMS_RANDOM package provides a mechanism for generating random numbers. Use the INITIALIZE procedure to set the seed value, which is used by the random number generator to generate the numbers. Periodically, the seed procedure value should be changed, to reduce the possibility of repeating values, especially if a number of repetitions have occurred,
The first step is to register the datablade in your logging database (Logging is required, and it has to be non-ANSI). This is accomplished as follows:
- Change directory to $INFORMIXDIR/extend/excompat.1.0
- Start the blademanager interface from a command line, using this command sequence:
- show databases (select the logged database from the resulting display, which you want to use.. In this example it is stores_demo).
- list stores_demo (by default, timeseries, ifxrltree, and spatial are already registered for stores_demo. Confirm that excompat.1.0 is not among them.)
- show modules (this command will list the module names available to be registered. It has to follow the list command.)
- register excompat.1.0 stores_demo (once it is registered, a success message is returned).
- quit (this will exit the blademgr interface)
Once the datablade module is registered, five packages are available for use. Of the five packages, the DBMS_RANDOM package provides 4 routines:
Initialize procedure: This routine initializes the system package and seeds an initial value for the randomizer. Functionally it is similar to the seed procedure, so it is optional whether it is used or not.
Sample usage: execute procedure dbms_random_initialize (17809465);
Seed procedure: This routine seeds (or resets) the integer value for the randomizer.
Sample usage: execute procedure dbms_random_seed (-45902345);
Random function: The random function uses the seed value to return a random integer.
Sample usage: execute procedure dbms_random_random();
(This would return a value. dbms_random_random() can also be used in any sql statement.).
Sample usage: execute procedure dbms_random_terminate();