title: Alter sequence .nextval in Oracle SQL 11 with prepared statement
body: <p>I'm trying to advance a sequence by a negative number but I keep getting the following error:</p>
  
  <blockquote>
    <p>ORA-02286: no options specified for ALTER SEQUENCE</p>
  </blockquote>
  
  <p>So far no amount of Googling has helped. The statement that I use is </p>
  
  <pre><code>ALTER SEQUENCE %s.nextval INCREMENT BY ?
  </code></pre>
  
  <p>The sequence name is generally <code>schema.table_name_seq</code>. Including the schema name is unavoidable because the connection is not necessarily to the same one.</p>
  
  <p>Appending an inconsequential option like <code>minvalue 1</code> did nothing to satisfy it either.</p>
  
  <p>My second attempt was to drop <code>.nextval</code> from the query and run <code>ALTER</code> directly on the sequence (just throwing stuff at the wall to see what sticks at this point), ie:</p>
  
  <pre><code>ALTER SEQUENCE %s INCREMENT BY ?
  </code></pre>
  
  <p>which results in</p>
  
  <blockquote>
    <p>ORA-01722: invalid number</p>
  </blockquote>
  
  <p>Next I supplied a positive integer and negated it in the query (<code>INCREMENT BY -?</code>) which produced the same error. The query is prepared as such:</p>
  
  <pre><code>num = -1 * Math.abs(num);
  
  stmt = conn.prepareStatement(sql);
  stmt.setLong(1, num); //also tried setInt()
  stmt.execute();
  </code></pre>
  
  <p>The idea is to set the <code>.nextval</code> sequence for a given table back to an arbitrary number (but always more than <code>minval</code>).</p>