title: Oracle: Setting sequence to a specific value
body: <p>I am using liquibase to manage my schema. I have a bunch of insert statements. I have hard coded the primary-id numbers. After all my inserts are done, I want to change the sequence value to 1 more than the maximum value of the primary-key in the table. For this I wrote a PL/SQL as given below. However, when I execute <code>select ArtifactTypes_id_seq.nextval from dual;</code> it still increments 0.</p>
  
  <pre><code>SET SERVEROUTPUT ON SIZE 1000000
  DECLARE
      sequence_id NUMBER;
  BEGIN
  
      SELECT NVL(MAX(idArtifactType), 0) + 1 INTO sequence_id FROM ArtifactTypes;
      EXECUTE IMMEDIATE 'ALTER SEQUENCE saas.ArtifactTypes_id_seq INCREMENT BY ' || sequence_id;
      EXECUTE IMMEDIATE 'SELECT ArtifactTypes_id_seq.nextval FROM dual';
      EXECUTE IMMEDIATE 'ALTER SEQUENCE saas.ArtifactTypes_id_seq INCREMENT BY 1';
      DBMS_OUTPUT.put_line('Executed "ALTER SEQUENCE saas.ArtifactTypes_id_seq INCREMENT BY ' || sequence_id || '"');
  END;
  /
  </code></pre>
  
  <p>The DBMS_OUTPUT gives following output -
  <br><code>Executed "ALTER SEQUENCE saas.ArtifactTypes_id_seq INCREMENT BY 71"</code></p>
  
  <p>Anything that I am missing out? Am I doing the wrong way?
  NOte: I tried executing these SQLs from SQLDeveloper.</p>