I'm attempting to display the count of all tables of a similar name in an Oracle database. The query will run via SQL*Plus at the command line. I've written the following code:
DECLARE
ctr number;
cursor to_check is
select table_name from user_tables
where table_name like '%REF%' or table_name like '%CNF%'
order by table_name;
BEGIN
set serveroutput on size 100000;
for rec in to_check loop
execute immediate 'select count(*) into :ctr from ' || rec.table_name;
dbms_output.put_line(rec.table_name || ' ' || ctr);
end loop;
END;
However, I'm not receiving the output of this code. Is there an issue with the dbms_output? Or am I missing a more elegant way of pulling and displaying this information?
set serveroutput on size 100000;beforeDECLARE, then convert that line starting withexecute immediatetoexecute immediate 'select count(*) from ' || rec.table_name into ctr;/on a separate line after theEND;