I generate some test data and use dbms_random . I came across some weird behavior when using dbms_random in a JOIN condition, which I cannot explain:
------------------------# test-data (ids 1 .. 3) With x As ( Select Rownum id From dual Connect By Rownum <= 3 ) ------------------------
Floor(dbms_random.value(1, 4) ) returns a random number from (1,2,3), so I expected all lines x be connected to random string x2 or maybe always the same random string x2 in case the random number is evaluated only once.
When I try several times, I get the following results:
(1) ID ID2 (2) ID ID2 (3) ---- ---- ---- ---- no rows selected. 1 2 1 3 1 3 2 3 2 2 3 3 2 3 3 2 3 3
What am I missing?
EDIT
SELECT ROWNUM, FLOOR(dbms_random.VALUE (1, 4)) FROM dual CONNECT BY ROWNUM <= 3
will get the result in this case, but why does the original request behave like this?
source share