Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

If InLineView Has RandValue, FetchFirst does not work correct.

Aketi JyuuzouAug 15 2016 — edited Aug 20 2016

SQL> select * from v$version;

BANNER                                                                        CON_ID

----------------------------------------------------------------------------  ------

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production       0

PL/SQL Release 12.1.0.2.0 - Production                                             0

CORE    12.1.0.2.0  Production                                                     0

TNS for Linux: Version 12.1.0.2.0 - Production                                     0

NLSRTL Version 12.1.0.2.0 - Production                                             0

SQL> select Val

  2  from (select mod(dbms_random.random(),123) as Val

  3          from dict)

  4  where Val >= 25

  5    and RowNum <= 5;

VAL

---

29

118

104

64

39

OK I Will Use Oracle12C New Feature "Fetch First"

SQL> select Val

  2  from (select mod(dbms_random.random(),123) as Val

  3          from dict)

  4  where Val >= 25

  5  Fetch First 5 rows Only;

VAL

----

  -6

-83

-77

-108

-17

My Question is Why Above Query Returns not more than 25 Vals ??? 

If Query does not have RandValue,It works correct.

SQL> select Val

  2  from (select column_value as Val

  3          from table(sys.OdciNumberList(1,2,3,4,5,30,31,32,33,34,35)))

  4  where Val >= 25

  5  Fetch First 5 rows Only;

VAL

---

30

31

32

33

34

This post has been answered by Solomon Yakobson on Aug 15 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2016
Added on Aug 15 2016
8 comments
1,238 views