VALUE functions
Translation reference for DBMS_RANDOM.VALUE.
Description
The basic function gets a random number, greater than or equal to 0 and less than 1. Alternatively, you can get a random Oracle number
X
, whereX
is greater than or equal tolow
and less thanhigh
. (Oracle PL/SQL DBMS_RANDOM.VALUE)
This UDF is implemented using the Math.random function of Javascript to replicate the functionality of Oracle DBMS_RANDOM.VALUE function.
Syntax
Custom UDF overloads
Setup data
The DBMS_RANDOM
schema must be created.
DBMS_RANDOM.VALUE()
Parameters
No parameters.
Note: The UDF only supports approximately between 9 and 10 digits in the decimal part of the number (9 or 10 digits of precision)
Usage example
Oracle
Note: The function can be called either_DBMS_RANDOM.VALUE()
_ or DBMS_RANDOM.VALUE.
Snowflake
Note: In Snowflake, you must put the parentheses.
DBMS_RANDOM.VALUE(NUMBER, NUMBER)
Parameters
low: The lowest
NUMBER
from which a random number is generated. The number generated is greater than or equal tolow
.high: The highest
NUMBER
used as a limit when generating a random number. The number generated will be less thanhigh
.
Notes:
The Oracle DBMS_RANDOM.VALUE(low, high) function does not require parameters to have a specific order so the Snowflake UDF is implemented to support this feature by always taking out the highest and lowest number.
The UDF only supports approximately between 9 and 10 digits in the decimal part of the number (9 or 10 digits of precision).
Usage example
Oracle
Snowflake
Known Issues
No issues were found.
Related EWIs
SSC-FDM-OR0033: DBMS_RANDOM.VALUE Built-In Package precision is lower in Snowflake.
Last updated