Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Return table name and record count
Bruce G. wrote:
> Hello Group,
> I was trying to write a script that returns the name of my tables and
> the number of records in each table. This is as close as I can get but
> keep getting a "PLS-00201: identifier 'TAB_NAME' must be declared"
> error. Am I making this more complicated than necessary?
> Thanks
>
> declare
> tab_name USER_TABLES.TABLE_NAME%TYPE;
> rec_count number;
> err_mssg varchar2(512);
> cursor tab_cur is
> select table_name from user_tables;
> tab_rec user_tables%rowtype;
> begin
> for tab_rec in tab_cur loop
> tab_name := tab_rec.table_name;
> select count(*) into rec_count from tab_name;
> dbms_output.put_line(tab_name||','||rec_count);
> end loop;
> exception
> when others then
> err_mssg :=sqlerrm;
> dbms_output.put_line(err_mssg);
> end;
> /
>
You can't do it that way. Look into Execute_Immediate or DBMS_SQL Received on Wed May 18 2005 - 10:47:44 CDT
![]() |
![]() |