How to set up and use DBMS_RANDOM (SQL package extension)
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:
DBMS_RANDOM_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.
DBMS_RANDOM_SEED procedure: This routine seeds (or resets) the integer value for the randomizer.
DBMS_RANDOM_RANDOM procedure: The random function uses the seed value to return a random integer.
DBMS_TERMINATE procedure: The TERMINATE procedure terminates the use of the system package by resetting the seed value to 0. Its usage is optional.
More support for:
Software version: 11.7, 12.1
Operating system(s): AIX, HP-UX, Linux, OS X, Solaris, Windows
Reference #: 1670986
Modified date: 24 September 2014