title: How to update exactly one record and select updated row in a single db2 query
body: <p>I want to write a query which updates only one row of a table then returns updated rows.</p>
  
  <p>I can achieve getting returned rows using </p>
  
  <pre><code>select field from final table 
  (update tablename set anotherfield = 'dd' where someanotherfield = 'bb')
  </code></pre>
  
  <p>kind of statement. But i cannot update just one row.</p>
  
  <p>Also my program that calls this query is a multithreaded one and i dont want to deadlock any processes so, i found SKIP LOCKED DATA statement which is like readpast in t-sql query.</p>
  
  <p>So what i am trying to do is, my program uses an db2 table like a stack, selects only one row each time, updates it so any other thread cannot access it but does not make them wait 
  entire table, they just skip updated row and select next record from table. Is this operation possible in a single db2 query?</p>
  
  <p>I have written this query so far, and it cannot be processed</p>
  
  <pre><code>select COLUMN3 FROM FINAL TABLE
     ( 
        update MYTABLE 
        set    COLUMN1 = 'R'
        where  COLUMN1 = ''
            order by COLUMN2 
            FETCH FIRST 1 ROW ONLY 
            SKIP LOCKED DATA 
     )
  </code></pre>
  
  <p>Any help would be appreciated, 
  Thanks.</p>