title: Dynamic SQL using 'where current of'
body: <p>I have a pretty generic/dynamic procedure where I pass in the table name as a parameter and execute queries dynamically using EXECUTE IMMEDIATE. I need to loop through a cursor and update each record. Is there a way to not have to hard code my table name??</p>
  
  <p>I tried this but it doesn't work:</p>
  
  <pre><code>    open cur for v_sql;
      loop
          fetch cur into v_recid;
          EXIT WHEN cur%NOTFOUND;
          EXECUTE IMMEDIATE 'update '||p_table||q'[ set status = 'I' where current of cur]'; 
      end loop;
      close cur;
  </code></pre>