Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Return table name and record count

Return table name and record count

From: Bruce G. <uv_katastrophe_at_yahoo.com>
Date: 18 May 2005 07:08:57 -0700
Message-ID: <1116425337.077987.182650@o13g2000cwo.googlegroups.com>


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;
/ Received on Wed May 18 2005 - 09:08:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US