SQL> select dbms_random.value(1,100) from dual;DBMS_RANDOM.VALUE(1,100)
------------------------
              71.8645205Elapsed: 00:00:00.30

解决方案 »

  1.   

    Before you can use the DBMS_RANDOM package, you must initialize it with this program.PROCEDURE DBMS_RANDOM.INITIALIZE (seed IN BINARY_INTEGER);
    seed The seed number used in the algorithm to generate a random number. You should provide a number with at least five digits to ensure that the value returned by the DBMS_RANDOM.RANDOM function will be sufficiently, well, random.The INITIALIZE procedure does not assert a purity level with the RESTRICT_REFERENCES pragma.
    ExampleHere is an example of a call to initialize the DBMS_RANDOM package:SQL> exec DBMS_RANDOM.INITIALIZE (309666789);then
    Call the RANDOM function to retrieve a random number.FUNCTION DBMS_RANDOM.RANDOM RETURN BINARY_INTEGER;The RANDOM runction does not assert a purity level with the RESTRICT_REFERENCES pragma.
    ExampleHere is an example of a call to RANDOM to obtain a random number:DECLARE
       my_random BINARY_INTEGER;
    BEGIN
       my_random := DBMS_RANDOM.RANDOM;