DBMS_RANDOM.INITIALIZE and DBMS_RANDOM.RANDOM : DBMS_RANDOM « System Packages « Oracle PL/SQL Tutorial






SQL>
SQL> DECLARE
  2     lv_seed_num   PLS_INTEGER := 123456789;
  3     lv_random_num PLS_INTEGER;
  4  BEGIN
  5     DBMS_RANDOM.INITIALIZE(lv_seed_num);
  6     FOR lv_loop_num IN 1..5 LOOP
  7        lv_random_num := DBMS_RANDOM.RANDOM;
  8        DBMS_OUTPUT.PUT_LINE('Loop: ' || lv_loop_num ||
  9           '   Random Number: ' || lv_random_num);
 10     END LOOP;
 11     DBMS_RANDOM.TERMINATE;
 12  END;
 13  /
Loop: 1   Random Number: 1476678237
Loop: 2   Random Number: -1196898280
Loop: 3   Random Number: -1383166668
Loop: 4   Random Number: 676298547
Loop: 5   Random Number: 1488158419

PL/SQL procedure successfully completed.

SQL>








31.21.DBMS_RANDOM
31.21.1.DBMS_RANDOM.RANDOM()
31.21.2.DBMS_RANDOM.INITIALIZE and DBMS_RANDOM.RANDOM