title: Oracle : How to have only one row active in a table?
body: <p>I have an Oracle table with a field Named <strong>Active</strong>.
  This field has a unique constraint, so only one row will be marked as Active.</p>
  
  <p>Is there any way in the <strong>database</strong> layer to keep only one row active when adding a new row or updating old ones ?</p>
  
  <p>Example </p>
  
  <p>Current State of Table</p>
  
  <pre><code>ID        Active
  ----------------
  1         yes
  </code></pre>
  
  <p>A new active row is added :</p>
  
  <p>New State of the table</p>
  
  <pre><code>ID        Active
  ----------------
  1         No
  2         Yes
  </code></pre>
  
  <p>The row 1 is updated with Active = Yes</p>
  
  <pre><code>ID        Active
  ----------------
  1         Yes
  2         No
  </code></pre>
  
  <p>Of course I can not update the table using a trigger when a new row is beign inserted.</p>
  
  <p>Does anyone have an idea on how to do that please ?</p>