Sometimes you need unique random number. Here is code for PL/SQL
FUNCTION GetRandNumber RETURN Number IS
l_seed BINARY_INTEGER;
l_random_num NUMBER(5);
l_date VARCHAR2(25);
l_random VARCHAR2(4);
BEGIN
l_seed := TO_NUMBER(TO_CHAR(SYSTIMESTAMP, 'FF'));
DBMS_RANDOM.initialize (val => l_seed);
l_random_num := TRUNC(DBMS_RANDOM.value(low => 1, high => 65535));
DBMS_RANDOM.terminate;
return l_random_num;
END GetRandNumber;
No comments:
Post a Comment