with
function
getrand(pval in number) return number is --- many more times we get a result set (we aren't even using the parameter)
-- getrand return number is --- many fewer times we get a result set (yes, keep trying, it does happen)
begin
return round(dbms_random.value(0,20));
end;
my_rnd as
(
select object_id, getrand(object_id) getrnd from all_objects
-- select object_id, getrand getrnd from all_objects
)
select * from my_rnd where getrnd = 10;
OBJECT_ID | GETRND | 538 | 14 | 1777 | 11 | 1799 | 16 | 1827 | 0 | 1963 | 15 | 2045 | 9 | 2057 | 4 | 2069 | 6 | 2071 | 15 | 2095 | 4 | 2151 | 2 | 2183 | 7 | 2201 | 13 | 2211 | 1 | 2264 | 12 | 2268 | 9 | 2288 | 17 | 2328 | 16 | 2358 | 2 | 2378 | 18 | 2424 | 19 | 2440 | 0 | 2460 | 1 | 2500 | 5 | 2624 | 14 | 2710 | 1 | 2728 | 1 | 2732 | 15 | 2752 | 15 | 2794 | 16 | 2820 | 14 | 3001 | 20 | 3017 | 8 | 3021 | 10 | 3025 | 9 | 3049 | 4 | 3121 | 13 | 3143 | 16 | 3203 | 9 | 3217 | 14 | 3229 | 11 | 3245 | 13 | 3301 | 9 | 3321 | 3 | 3361 | 16 | 3439 | 6 | 3604 | 17 | 3632 | 19 | 3662 | 9 | 3690 | 16 |
---|