Home » RDBMS Server » Server Administration » Number of rows
Number of rows [message #371774] Mon, 04 December 2000 13:08 Go to next message
Marcus Fernando
Messages: 34
Registered: September 2000
Member
I'm trying do make a procedure that reads the catalog from a scheme and lists the number of rows of each table. My code is :

PROCEDURE TESTE IS
CURSOR C1 IS
SELECT TABLE_NAME
FROM USER_TABLES
ORDER BY 1;
NumRegs integer;
Name_Table varchar2(30);

BEGIN

FOR C1A IN C1 LOOP
Name_Table := C1A.Table_name;
DBMS_OUTPUT.PUT_LINE(Name_Table);
SELECT COUNT(*) into NumRegs
FROM Name_Table;
DBMS_OUTPUT.PUT_LINE(NumRegs);
END LOOP;

END;

And i heve the error:
PLS-00356: 'NAME_TABLE' must name a table to which the user has access.
How can i use a variable in a sql statement like this ?

Thanks.
Re: Number of rows [message #371779 is a reply to message #371774] Mon, 04 December 2000 16:37 Go to previous messageGo to next message
chandra
Messages: 31
Registered: October 2000
Member
In case you wish to pass a variable as a table name, you have to use DBMS_SQL package and parse the SQL statement. R&D how to use DBMS_SQL package
Re: Number of rows [message #371781 is a reply to message #371779] Tue, 05 December 2000 06:24 Go to previous message
Marcus Fernando
Messages: 34
Registered: September 2000
Member
OK, thanks. It works ..
Previous Topic: user question
Next Topic: use tablename in variable
Goto Forum:
  


Current Time: Wed May 01 21:42:50 CDT 2024