I was trying to do "select count(*) from tables" in PL/SQL similar to the folowing:
cursor cur is select table_name from user_tables;
for v_tabname in cur
select count(*) into v_count from v_tabname;
/* process v_coutn */
But I got 'V_TABNAME' must be declared error message. Can anyone point out where I made mistakes?
10-30-2000, 06:38 PM
You will need to use dynamic SQL to do this sort of stuff.
11-03-2000, 11:56 AM
If you are pre 8i you need to use DBMS_SQL package. In 8i (and maybe 8) you can use the statement EXECUTE IMMEDIATE like this:
EXECUTE IMMEDIATE 'select count(*) from ' || v_tabl_name INTO v_count;