title: Reset seq increment if seq.nextval is lower than the max id value
body: <p>Writing a stored procedure that will insert records into a table.  I am having an issue with setting the <code>seq.nextval</code> value.  In the  table  am inserting into, it appears that at times the max id value in the table is higher than the value indicated for the <code>nextval</code>.  </p>
  
  <pre><code>SELECT TABLE_SEQ.NEXTVAL AS CASE_ID
  FROM DUAL;
  </code></pre>
  
  <blockquote>
    <p>CASE_ID<br>
    1015</p>
  </blockquote>
  
  <pre><code>SELECT MAX(CASE_ID) AS CASE_ID
  FROM CASE_TABLE;
  </code></pre>
  
  <blockquote>
    <p>CASE_ID<br>
    2015</p>
  </blockquote>
  
  <p>I need to check what the <code>nextval</code> is for the table and then compare to the Maximum value of the ID field, if the <code>nextval value is lower than the Max id value, I need to increment the</code>nextval` value until it is higher than the max id value by 1.</p>
  
  <p>New to Oracle's SQL Developer tool, I've been researching how to do this, but can't find an approach. Does anyone have any idea's to share?  </p>
  
  <p>Thanks so much!!!!</p>