title: Oracle stored function - pass table name as parameter
body: <p>I'm trying to create a stored function in Oracle that will count the table rows..i want to make the table name dynamic, so i passed it as a parameter, the stored function code looks like this</p>
  
  <pre><code>create type tes_jml_obj is object(jumlah integer);
  create type tes_jml_table is table of tes_jml_obj;
  create or replace function jumlahBaris(namatabel varchar)
  return tes_jml_table
  is
    tabel tes_jml_table := tes_jml_table();
  begin
    for r in (execute immediate 'select count(*) as jumlah from' || namatabel)
    loop
      tabel.extend;
      tabel(1) := tes_jml_obj(r.jumlah);
    end loop;
    return tabel;
  end;
  </code></pre>
  
  <p>But when i execute it, it returns errors. Am i missing something here? Is that the correct way to get the table rows dynamically?</p>