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 -> Re: Oracle Procedure Problem

Re: Oracle Procedure Problem

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Fri, 21 Apr 2006 17:52:03 +0200
Message-ID: <mnvh42p1vd23umluo52i8nhpdiqe2rojap@4ax.com>


On 21 Apr 2006 06:05:12 -0700, "Kuldeep" <kuldeepchitrakar_at_gmail.com> wrote:

>create procedure tab_rows
> IS
> tab_name varchar(50);
> declare cursor all_tabs is
> select table_name
> from user_tables;
> begin
> create table temptab (rowc number (10));
> open all_tabs;
> Loop
> fetch all_tabs into tab_name;
> insert into temptab(rowc) select
>count(*) from tab_name;
> exit when all_tabs%notfound;
> End loop;
> close all_tabs;
> End;
>
>temptab has only one column rowc(number)
>
>Objective : ; procedure will return count(*) of all user tables.
>
>But above procedure is giving Error :Procedure created with compilation
>errors.
>
>Can anybody has workaround over it

create function tab_rows return number is dummy number;
temp number;
begin
dummy := 0;
for tab in (select table_name from user_tables) loop execute immediate 'select count(*) from '||tab.table_name into temp; dummy := dummy + temp;
end loop;
return dummy;
end;
/

--
Sybrand Bakker, Senior Oracle DBA
Received on Fri Apr 21 2006 - 10:52:03 CDT

Original text of this message

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