title: Does DB2 have an "insert or update" statement?
body: <p>From my code (Java) I want to ensure that a row exists in the database (DB2) after my code is executed.</p>
  
  <p>My code now does a <code>select</code> and if no result is returned it does an <code>insert</code>.  I really don't like this code since it exposes me to concurrency issues when running in a multi-threaded environment.</p>
  
  <p>What I would like to do is to put this logic in DB2 instead of in my Java code.
  Does DB2 have an <code>insert-or-update</code> statement? Or anything like it that I can use?</p>
  
  <p>For example:</p>
  
  <pre><code>insertupdate into mytable values ('myid')
  </code></pre>
  
  <p>Another way of doing it would probably be to always do the insert and catch "SQL-code -803 primary key already exists", but I would like to avoid that if possible.</p>