DECLARE
tablename varchar(500);
vsql varchar(500);
vcount int;
vcount1 int;
cursor emp_cursor is select table_name from user_tables;
BEGIN
vcount:=1;
vcount1:=1;
tablename:='oc_gz_trip_report';
OPEN emp_cursor;
LOOP
FETCH emp_cursor INTO tablename;
vsql:='select count(1),count(1) from '|| tablename ;
DBMS_OUTPUT.PUT_LINE(vsql);
execute immediate vsql into vcount,vcount1;
DBMS_OUTPUT.PUT_LINE(tablename||' '||vcount||' '||vcount1);
EXIT WHEN emp_cursor%NOTFOUND;
END LOOP;
close emp_cursor;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);
END;