In Oracle Sql developer 11g, how do I generate a random integer and assign it to a variable? This is what I\'ve tried so far:
S_TB := SELECT dbms_random.value(1,
Alternatively, You can create a function for generating random numbers. This can be used in anywhere in the code.
create or replace function RANDOM
return number
is
a number ;
begin
select round(dbms_random.value(1,10)) rnum
into a
from dual;
return a ;
end;
/
OUTPUT:
Function created.
SQL> select Random from dual;
6
SQL> select Random from dual;
9