title: Implementing Optimistic Locking in Oracle
body: <p>I am confused about the subject of locking in Oracle. As far as my research has lead me, you can use the <code>FOR UPDATE NOWAIT/WAIT</code> to lock rows.</p>
  
  <p>I want to implement my locking this way. Once I issue the <code>FOR UPDATE</code>, the row will then be locked and I can check for mutations. I have a versionNumber column that increments by 1 everytime the table is updated. Can i use this versionNumber to verify the row has or hasn't mutated? something like</p>
  
  <p><code>if (:new.versionNum != :old.versionNum)
           raise_application_error(20000, 'Mutated');
   end if;</code></p>
  
  <p>My question is where do I go about actually writing the line of code <code>FOR UPDATE</code>? I've made a small GUI to handle changing first names and saving them back to the database. Is this done in a trigger on oracle on that table or on the side of my JDBC client?</p>
  
  <p>Any clarification would be nice! </p>
  
  <p>Thanks</p>