I'm confused, because I don't know how to use variable as string in execute immediate
clause.
declare
variable1 varchar2(30):
cur sys_refcursor;
begin
open cur for
select tablename from table1;
loop
fetch cur into variable1;
exit when cur %notfound;
execute immediate 'select count(*)
into variable1
from user_tables
where table_name =''' || variable1 || '''';
end loop;
close cur;
end;
Here variable1
is a table name. There should be a string value. How to do that? Still got an error.