title: Postgres UPSERT on any constraint
body: <p>In MySQL we can do the following on any constraint violation</p>
  
  <pre><code>INSERT INTO table {setters} ON DUPLICATE KEY UPDATE {setters}
  </code></pre>
  
  <p>Is there anyway to do this in Postgres ? </p>
  
  <pre><code>INSERT INTO table {setters} ON CONFLICT(*) DO UPDATE {setters}
  </code></pre>
  
  <p>Note: * = Any Possible Key</p>
  
  <p>Why is this an important feature? </p>
  
  <ul>
  <li>I want to make this code generic across multiple tables. So, I can't specify the keys as per current Postgres 9.5 syntax (Someone might argue, I could possibly store the keys on all tables and change the keys dynamically. First of all its not elegant and there is the following problem)</li>
  <li>While the application is live, some new unique constraints could be added at run time. So, you can't specify this in your code at Compile time</li>
  <li>Another Alternative is: In your app, you first try to insert and when there is a Duplicate key error, you catch catch it and try to do an update. This is really bad, as this is 
  
  <ol>
  <li>Not an atomic operation </li>
  <li>The latency between app server and the DB server doubles.</li>
  <li>Bulk insert is not possible</li>
  </ol></li>
  </ul>