title: oracle: For update select first 10 rows
body: <p>I have an <code>ITEM</code> table with one of the column as <code>CREATED_DATE</code>. In a clustered enviroment, many copies of services will pick items from this table and process it. Each service should pick the oldest 10 items from the ITEM table.</p>
  
  <p>I am able to select top 10 rows using this in a Stored Procedure:</p>
  
  <pre><code>select * from (
      select  item_id, row_number() over (order by CREATED_DATE) rownumber
      FROM item )
  where rownumber &lt; 11
  </code></pre>
  
  <p>Since many service should use this, I am using <code>select ... for update</code> to update the rows as "processing". But the below <code>FOR UPDATE</code> statement, fails for the above select statement with error "ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc."</p>
  
  <pre><code>OPEN items_cursor FOR
  **select Statement**
  FOR UPDATE;
  </code></pre>
  
  <p>Please help me with a solution.</p>