title: Incrementing Oracle Sequence by certain amount
body: <p>I am programming a Windows Application (in Qt 4.6) which - at some point - inserts any number of datasets between 1 and around 76000 into some oracle (10.2) table. The application has to retrieve the primary keys, or at least the primary key range, from a sequence. It will then store the IDs in a list which is used for Batch Execution of a prepared query.</p>
  
  <p>(Note: Triggers shall not be used, and the sequence is used by other tasks as well)</p>
  
  <p>In order to avoid calling the sequence X times, I would like to increment the sequence by X instead.</p>
  
  <p>What I have found out so far, is that the following code would be possible in a procedure:</p>
  
  <pre><code>ALTER SEQUENCE my_sequence INCREMENT BY X;
  
  SELECT my_sequence.CURVAL + 1, my_sequence.NEXTVAL
  INTO   v_first_number, v_last_number
  FROM   dual;
  
  ALTER SEQUENCE my_sequence INCREMENT BY 1;
  </code></pre>
  
  <p>I have two major concerns though:</p>
  
  <ol>
  <li>I have read that ALTER SEQUENCE produces an implicit commit. Does this mean the transaction started by the Windows Application will be commited? If so, can you somehow avoid it?</li>
  <li><p>Is this concept multi-user proof? Or could the following thing happen:</p>
  
  <pre><code>Sequence is at 10,000
  Session A sets increment to 2,000
  Session A selects 10,001 as first and 12,000 as last
  Session B sets increment to 5,000
  Session A sets increment to 1
  Session B selects 12,001 as first and 12,001 as last
  Session B sets increment to 1
  </code></pre>
  
  <p>Even if the procedure would be rather quick, it is not that unlikely in my application that two different users cause the procedure to be called almost simultaneously</p></li>
  </ol>