igormukhin
asked on
Variable table name in FROM of a SELECT in PL/SQL
Hallo all,
I want to output number of rows in 10 tables.
1) how to make the attached code work in Oracle 10? I get "ORA-00933: SQL-Befehl wurde nicht korrekt beendet" on the line "select count(*) into n from mytables(i);"
2) it there a better way to accomplish my task?
Thanks
I want to output number of rows in 10 tables.
1) how to make the attached code work in Oracle 10? I get "ORA-00933: SQL-Befehl wurde nicht korrekt beendet" on the line "select count(*) into n from mytables(i);"
2) it there a better way to accomplish my task?
Thanks
declare
type tables_varray is varray(10) of varchar2(100);
mytables tables_varray := tables_varray('MPM_MITA', 'MPM_ORGA', 'MPM_VEBE', 'MPM_FUNK', 'LIS_RV', 'BVS_BV', 'BVS_BV_BESTELLUNG', 'BVS_BV_BIETER', 'BVS_KONTAKT', 'BVS_FRZGPROJ');
n number;
begin
FOR i in mytables.first .. mytables.last LOOP
select count(*) into n from mytables(i);
dbms_output.put_line(mytables(i) || ': ' || n);
END LOOP;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.