title: Returning dataset with PL/SQL and a variable table name
body: <p>I'm trying to write a PL/SQL function to store a select statement with a variable table name (a bit weird i know but it is actually a good design decision). The following code does not work...but I'm not sure how to both take a variable table name (building the query) and return a dataset. Anyone have any experience in this? TIA.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION fn_netstat_all (casename in varchar2) 
  RETURN  resultset_subtype
  IS
    dataset resultset_subtype;
    v_sql varchar2(25000);
    v_tablename varchar2(50);
  
  begin
  
    v_sql := 'SELECT * FROM ' || casename || '_netstat;'; 
  
    OPEN dataset FOR
      execute immediate v_sql;
    return dataset;
  
  end;
  </code></pre>