title: Oracle/SQL - Select specified range of sequential records
body: <p>I'm tryint to select a subset of records, 5000 through 10000 from a join.  I've gotten queries like this to work in the past, but they were slightly less complex.  Here is the query I'm trying to use and if I remove the rownum/rnum references (and therefore the outer select) I receive all my records as expected so I know that logic is good.  </p>
  
  <pre><code>SELECT      * 
      FROM    ( 
              SELECT  unique cl.riid_, 
                      rownum as rnum 
              FROM    &lt;table 1&gt; cl, &lt;table 3&gt; mil 
              WHERE   cl.opt = 0 AND 
                      (cl.st_ != 'QT' OR cl.st_ IS NULL) AND 
                      cl.hh = 0 AND 
                      cl._ID_ = mil._ID_ AND 
                      mil.TYPE in (0, 1, 2, 3, 4) AND 
                      EXISTS 
                          ( SELECT    'x' 
                              FROM    &lt;table 2&gt; sub 
                              WHERE   cl.ea_ = lower(sub.ea_) AND 
                                      sub.status = 0 AND 
                                      lower(sub.subscription) = 'partner' 
                          ) AND 
                      rownum &lt;= 10000 
              ) 
      where   rnum &gt; 5000
  </code></pre>
  
  <p>So when I run this query I receive this message from our system (this is not an Oracle cli interface, but rather a web layer that exists over the top of it so please bare with the error msg if it's out of the ordinary) </p>
  
  <p><em>'Error: The resource selected for viewing is invalid. You may need to re-create or fix the object before viewing its data.'</em></p>
  
  <p>The resource would be the results of the query. </p>
  
  <p>So does anyone have an idea of whats going on or a better way to do this?</p>
  
  <p>Thanks!</p>