title: Oracle stored procedure thread-safe?
body: <p>Pseudo code:</p>
  
  <ol>
  <li><p>begin stored procedure</p></li>
  <li><p>commit</p></li>
  <li><p>check the value  column 1 of row a //step 1</p></li>
  <li><p>update column 1 of row a //step 2</p></li>
  <li><p>commit</p></li>
  <li><p>end stored procedure</p></li>
  </ol>
  
  <p>Is this sp thread safe?  </p>
  
  <h3>edit:</h3>
  
  <pre><code>Declare
    tag_rec prep_tag%ROWTYPE;
  begin
  
    COMMIT; 
  
    SELECT * INTO tag_rec 
    FROM PREP_TAG 
    WHERE project = 'a' and categoryId = 'b'; 
  
    if tag_rec.locked = 'No' then
  
      UPDATE prep_tag 
      SET locked = 'Yes' 
      WHERE TAG_NUMBER = tag_rec.TAG_NUMBER;
  
    end if;
  
    COMMIT; 
  
  end;
  </code></pre>
  
  <p>Is this sp thread safe?  Is it possible that thread A checked tag_rec.locked = 'No' then it's about to update it. But before it does that, thread B sneaks in and also see tag_rec.locked = 'No'?</p>