title: Oracle: How to use procedure local variables for "EXECUTE IMMEDIATE" statements in procedures
body: <p>We have a procedure starting with following code:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE get_id
    (id_ IN OUT number, type_ IN number)
  IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    local_id number;
  BEGIN
    EXECUTE IMMEDIATE 'SELECT SYS_LOCAL_ID_SERIAL_SEQ.NEXTVAL into :local_id FROM dual';
    ...
  </code></pre>
  
  <p>Now if i execute this, the variable "local_id" is not filled with the next sequence value, but with null (although the sequence is raised by 1). If i change this to "... into local_id ..." i get ORA Error 1008 . What is going wrong here?</p>