ROUND a DBMS_RANDOM.VALUE : DBMS_RANDOM « System Packages « Oracle PL / SQL






ROUND a DBMS_RANDOM.VALUE

   
SQL>
SQL> CREATE OR REPLACE FUNCTION get_num (
  2     p_highval   NUMBER,
  3     p_lowval    NUMBER := 0,
  4     p_scale     PLS_INTEGER := 0
  5  )
  6     RETURN NUMBER
  7  IS
  8     l_ret   NUMBER;
  9  BEGIN
 10     l_ret := ROUND (DBMS_RANDOM.VALUE (p_lowval, p_highval), p_scale);
 11     RETURN l_ret;
 12  END;
 13  /

Function created.

SQL>
SQL> select get_num(5,2,2) from dual;

GET_NUM(5,2,2)
--------------
          4.27

   
    
  








Related examples in the same category

1.This script illustrates the use of the DBMS_RANDOM package.
2.Call dbms_random.normal to get a random number
3.Use dbms_random.string to create random string
4.dbms_random.value
5.Random string with dbms_random.string
6.Seed a random value with dbms_random.seed
7.Round a random value from dbms_random.value
8.trunc a random value from dbms_random.value
9.mod(abs(dbms_random.random),50000)+1
10.Insert random numbers into a table
11.Insert random value to table