how to get count(*) value in local temp variable in dynamic sql (ORACLE PLSQL)
Maybe different oracle version, but what worked for me was:
...
execute immediate 'select count(*) from ' || p_table_name into l_count;
...
You can achieve it with EXECUTE IMMEDIATE ... RETURNING INTO:
function count_rows(p_table_name varchar2)
return number
is
l_count number;
begin
execute immediate 'select count(*) from ' || p_table_name into l_count;
return l_count;
end count_rows;