December 2003
Intermediate to advanced
448 pages
9h 5m
English
You use the DBMS_RANDOM package to generate random numbers. You set the seed with the SEED function, which is overloaded.
PROCEDURE seed(val IN BINARY_INTEGER); PROCEDURE seed(val IN VARCHAR2);
Two methods for setting a seed are:
dbms_random.seed(123456); dbms_random.seed(TO_CHAR(SYSDATE,'dd-mon-yyyy hh24:mi:ss');
The function VALUE generates a 38-digit precision number within the range:
0.0 <= value < 1.0
The function definition for a random number is:
FUNCTION value RETURN NUMBER;
The following block illustrates the VALUE function.
DECLARE
N NUMBER;
BEGIN
dbms_random.seed(123456);
N := dbms_random.value;
-- N will be a number similar to:
--
-- 0.92531681298113309873787795771931592618
END;
You can generate ...
Read now
Unlock full access