How to set up and configure DBMS_RANDOM (SQL package extension)

Technote (FAQ)


Question

What are the requirements and steps to set up a database to use DBMS_RANDOM functions?

Cause

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,

Answer

Setup:

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:

  1. Change directory to $INFORMIXDIR/extend/excompat.1.0
  2. Start the blademanager interface from a command line, using this command sequence:
    • blademgr
      • 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)

Configuration

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.).

    Terminate procedure: The TERMINATE procedure terminates the use of the system package by resetting the seed value to 0. Its usage is optional.

      Sample usage: execute procedure dbms_random_terminate();

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Informix Servers

Software version:

11.7, 12.1

Operating system(s):

AIX, HP-UX, Linux, Mac OS X, Solaris, Windows

Reference #:

1670986

Modified date:

2014-06-30

Translate my page

Machine Translation

Content navigation