title: Calling stored procedure in for-loop
body: <p>I have created and stored a procedure in SQL Developer. I can call it and it is working as expected.</p>
  <p>However if I try to use it in a for-loop over a set of tables I get the error:</p>
  <blockquote>
  <p>ORA-06512: in line 10</p>
  <ol start="900">
  <li>00000 -  &quot;invalid SQL statement&quot;</li>
  </ol>
  </blockquote>
  <p>This is the procedure:</p>
  <pre><code>create or replace PROCEDURE ADD_PARAMETERS 
  (
    TBL_NAME IN VARCHAR2 
  ) AS 
  BEGIN
    
    EXECUTE IMMEDIATE 'ALTER TABLE '||TBL_NAME||' ADD(FB_AREA_HA Float)';
    
    EXECUTE IMMEDIATE 'UPDATE '||TBL_NAME||' SET FB_AREA_HA = FB_AREA/10000';
  END ADD_PARAMETERS;
  </code></pre>
  <p>And here the for-loop with the procedure:</p>
  <pre><code>SET SERVEROUT ON
  DECLARE
  
  sql_stmnt VARCHAR2(400);
  
  BEGIN
      FOR x in (SELECT * FROM all_tables WHERE table_name LIKE 'BBX_%')
      LOOP
          sql_stmnt := 'EXECUTE ADD_PARAMETERS('''||x.TABLE_NAME||''')';
          DBMS_OUTPUT.PUT_LINE(sql_stmnt||';');
          EXECUTE IMMEDIATE sql_stmnt;
      END LOOP;
  END;
  </code></pre>
  <p>What is the cause of this error? I'm pretty certain it is not line 10 though.</p>