Number of rows [message #371774] |
Mon, 04 December 2000 13:08 |
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 |
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
|
|
|
|