可以直接将表名当作变量传入function或procedure中
create or replace function(procedure) test (tablename in varchar2)
as
  type v_cursor is ref cursor;
  v_tempcursor v_cursor;
  i number;
begin
  open v_tempcursor for 'select id from ' || tablename;
  loop
    fetch v_tempcursor into i;
    dbms_output.put_line('i:' || i || ';');
    exit when v_tempcursor%NOTFOUND;
  end loop;
end;
随便写的没有测试。