DBE_RANDOM
Interface Description
Table 1 lists all interfaces supported by the DBE_RANDOM package.
Interface |
Description |
---|---|
Sets a seed for a random number. |
|
Generates a random number between a specified low and a specified high. |
- DBE_RANDOM.SET_SEED
The stored procedure SEED is used to set a seed for a random number. The function prototype of DBE_RANDOM.SET_SEED is as follows:
1
DBE_RANDOM.SET_SEED (seed IN INTEGER);
Table 2 DBE_RANDOM.SET_SEED interface parameters Parameter
Description
seed
Generates a seed for a random number.
- DBE_RANDOM.GET_VALUE
The GET_VALUE function generates a random number between a specified low and a specified high. The prototype of the DBE_RANDOM.GET_VALUE function is as follows:
1 2 3 4
DBE_RANDOM.GET_VALUE( min IN NUMBER default 0, max IN NUMBER default 1) RETURN NUMBER;
Table 3 DBE_RANDOM.GET_VALUE interface parameters Parameter
Description
min
Sets the low bound for a random number. The generated random number is greater than or equal to min.
max
Sets the high bound for a random number. The generated random number is less than max.
- The only requirement is that the parameter type is NUMERIC regardless of the right and left bound values.
- DBE_RANDOM implements pseudo-random numbers. Therefore, if the initial value (seed) remains unchanged, the sequence of the pseudo-random numbers also remains unchanged.
- The generated random number contains 15 valid digits.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 |
-- Generate a random number between 0 and 1. SELECT DBE_RANDOM.GET_VALUE(0,1); get_value ------------------ .917468812743886 (1 row) -- For integers within a specified range, add the arguments min and max, and truncate the decimals from the result (the maximum value is not included as a possible value). Therefore, for integers from 0 to 99, you can use the following code: SELECT TRUNC(DBE_RANDOM.GET_VALUE(0,100)); trunc ------- 26 (1 row) |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot