title: Execute immediate within Oracle Procedure
body: <p>I have two users: SASDBA and CDM. 
  There is a procedure in schema SASDBA which keeps objects into the buffer pool.
  Part of a procedure:</p>
  
  <pre><code>BEGIN
                FOR TABLE_ENTRY IN
                (SELECT          *
                FROM dba_tables
                WHERE owner = t_owner
                AND TABLE_NAME    = t_name_obj
                )
                LOOP
  EXECUTE immediate 'alter table '||TABLE_ENTRY.OWNER||'.'||TABLE_ENTRY.TABLE_NAME||' storage (buffer_pool keep)';
      END LOOP;
  END;
  </code></pre>
  
  <p>So, if I try to pass CDM.TABLE_TEST into the procedure I get an error:</p>
  
  <blockquote>
    <p>ORA-01031: insufficient privileges</p>
  </blockquote>
  
  <p>But, if user SASDBA alters it without procedure it works:</p>
  
  <pre><code>alter table CDM.TEST_TABLE  storage (buffer_pool keep)
  </code></pre>
  
  <blockquote>
    <p>table CDM.TEST_TABLE altered.</p>
  </blockquote>