Time Based Random Seed Creation
SET SERVEROUTPUT ON;

DECLARE
 multiplier   CONSTANT SIMPLE_INTEGER := 2669477;
 idx          CONSTANT SIMPLE_INTEGER := 1;

 "2^32"       CONSTANT NUMBER := 2 ** 32;

 "2^16"       CONSTANT SIMPLE_INTEGER := 2 ** 16;
 "0x7fff"     CONSTANT SIMPLE_INTEGER := 32767;

 seed         NUMBER := TO_CHAR(SYSDATE,'JSSSSS');

BEGIN
 DBMS_OUTPUT.PUT_LINE('Constant 2^16 value     = '||"2^16");
 DBMS_OUTPUT.PUT_LINE('Constant 2^32 value     = '||"2^32");
 DBMS_OUTPUT.PUT_LINE('Constant "0x7fff" value = '||"0x7fff"); 

 DBMS_OUTPUT.PUT_LINE('Initial seed value      = '||seed);

 seed := MOD(multiplier * seed + idx, "2^32");
 DBMS_OUTPUT.PUT_LINE('Next seed value         = '||seed);

 seed := BITAND(seed/"2^16", "0x7fff");
 DBMS_OUTPUT.PUT_LINE('Next seed value         = '||seed);
END;
/

BITAND Function

DBMS_RANDOM value

Oracle Function

Oracle registered trademark of Oracle Corporation.

Last Revised On: May 31st, 2014

  265