Oracle Cryptographic Toolkit Programmer's Guide
Release 2.0.4

A54082-02

Library

Product

Contents

Index

Prev Next

5
Random Number Generator

This chapter discusses the Oracle Cryptographic Toolkit random number generator. The following topics are covered:

5.1 Overview

The random number generator is built on top of the Oracle Cryptographic Toolkit. This tool is intended for users who want to generate random data for their applications.

5.2 Functions

The random number generator is composed of the following:

PROCEDURE Initialize (seed IN BINARY_INTEGER)

This procedure is used before the random number generator package is called. The procedure takes a seed which initializes the random number generator. The seed can be any value between -9999999999 and 9999999999.


Note:

You must call this procedure before using any of the other procedures or functions. Otherwise, an exception will be raised.

 

PROCEDURE Seed (seed IN BINARY_INTEGER)

This procedure resets the seed used by the random number generator.

FUNCTION Random RETURN BINARY_INTEGER

The function returns a random number between -9999999999 and 9999999999.

PROCEDURE Terminate

This procedure must be called when the package is no longer needed.

5.3 Example

The following code fragment is an example of how to use the random number generator package.

DECLARE 
    i BINARY_INTEGER; 
BEGIN 
    dbms_random.initialize(19254); 
    i := dbms_random.random; 
    INSERT INTO some_table VALUES(i); 
    dbms_random.terminate; 
END; 


Note:

It is not currently possible to use the return value of RANDOM directly in a SQL statement. The following is not allowed, for example:

INSERT_INTO some_table VALUES(DBMS_RANDOM.RANDOM); 
 




Prev

Next
Oracle
Copyright © 1997 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index