title: Retrieve next value of Oracle sequence via stored procedure
body: <p>I have created a SEQUENCE in Oracle11g which is working as expected. The challenge is that I need to retrieve the next value of the sequence via a stored procedure (because the application I'm using can only call a stored procedure not a sql statement).</p>
  
  <p>I have looked all over and the closest I've found is this (here: <a href="https://community.oracle.com/thread/2216649" rel="nofollow">https://community.oracle.com/thread/2216649</a>):</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE CSDWH.CSDWH_RETURN_SEQ_NUM 
  (SEQ_NAME IN VARCHAR2,SEQUENCE_OUT OUT NUMBER) 
  IS 
  BEGIN   
  EXECUTE IMMEDIATE 'SELECT ' || SEQ_NAME || '.NEXTVAL from dual' INTO sequence_out; 
  END;
  </code></pre>
  
  <p>The issue with this is the way of execution:</p>
  
  <pre><code>declare
    l_val number;
  begin
    csdwh_return_seq_num( 'FOO_SEQ', l_val );
    dbms_output.put_line( l_val );
  end;
  </code></pre>
  
  <p>The application I need to execute the stored procedure only have a connection string alias, a stored procedure name, and a return parameter field to be specified. The way to execute this stored procedure required 6 lines of code. </p>
  
  <p>Is there any way to achieve the above with the EXECUTE command?</p>
  
  <pre><code>i.e. EXECUTE CSDWH.CSDWH_RETURN_SEQ_NUM 
  </code></pre>
  
  <p>that would return the value?</p>