Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting record count from each tables from tab view

JCFeb 26 2007 — edited Feb 26 2007
Hi
I just want to get no. of records in each table .
Probably it could be possible through single query, I just wrote following code...but I get some error....

**********************
1 declare
2 cursor c1 is select tname from tab where tabtype = 'TABLE' ;
3 tabname varchar2(1000) ;
4 i number := 1;
5 rc number ;
6 str varchar2(1000) ;
7 begin
8 open c1 ;
9 loop
10 fetch c1 into tabname ;
11 exit when c1%notfound ;
12 str := 'select count(*) into ' || rc || ' from ' || tabname || ' ; ' ;
13 execute immediate str ;
14 dbms_output.put_line(i || ' - ' || tabname || ' -- ' ||rc) ;
15 i := i + 1 ;
16 end loop ;
17 close c1 ;
18* end ;

**********************
Error is :-
declare
*
ERROR at line 1:
ORA-00936: missing expression
ORA-06512: at line 13

I have doubt whether we can use user cursor returned values in Execute immediate ...

can anyone here check this
Thanks in advance
JC
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2007
Added on Feb 26 2007
5 comments
629 views