Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> How can this be ? (rownum question)
I am trying to write a little piece of code to get "any record" from a
table (for testing purposes). I wrote the following:
SQL> select count(1) from user_objects;
COUNT(1)
617
SQL> select inv.object_name
2 from ( select rownum idx, object_name from user_objects ) inv
3 where inv.idx = 1 + trunc(dbms_random.value * 600)
4 /
Much to my surprise, as you can see below, the number of lines returned varies from 0 to N !!! How is it possible ??? Can ROWNUM be repeated inside the inline view ??? I am using Oracle 10.2.0.3 under RH linux.
OBJECT_NAME
SQL> / OBJECT_NAME
SQL> / OBJECT_NAME
![]() |
![]() |