title: postgres update after select
body: <p>I want to do the following in one go:</p>
  
  <pre><code>SELECT * FROM jobs WHERE status='PENDING';
  UPDATE jobs SET status='RUNNING' WHERE status='PENDING';
  </code></pre>
  
  <p>So get all pending jobs, then set them as 'RUNNING' immediately after.</p>
  
  <p>The reason I don't want to do it one after the other in two statements is that jobs could be added to the jobs table as 'PENDING' after the SELECT but before the UPDATE so I'd end up setting jobs as RUNNING even though I haven't grabbed it while it was in it's PENDING state.</p>
  
  <p>Is there anyway to do this in one?  So I want the result from SELECT and the UPDATE to happen on the fly.</p>
  
  <p>Thanks.</p>