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: print table name and the number of rows in it

Re: print table name and the number of rows in it

From: Björn Wächter <bwc_at_p3-solutions.de>
Date: Wed, 07 Dec 2005 11:12:39 +0100
Message-ID: <3vnqv4F16t35tU1@news.dfncis.de>


I do this job with a Stored Procedure:

CREATE OR REPLACE FUNCTION Get_Row_Num(

     p_table_name VARCHAR2
)

     RETURN NUMBER
IS

     v_return        NUMBER;
	v_sql           VARCHAR2(400);
	

BEGIN                  v_sql := 'SELECT COUNT(*) FROM ' || p_table_name;         

        EXECUTE IMMEDIATE v_sql INTO v_return;         

        RETURN v_return;

END Get_Row_Num;
/

SELECT
TABLE_NAME,
Get_Row_Num(TABLE_NAME) ROW_COUNT,
num_rows
FROM USER_TABLES The results are different sometimes.
But why? For me it looks like the stored procedure returns the correct result.

Björn

Arto Viitanen wrote:
> Sreelal wrote:
>

>> i want to print all the tables names owned by a user along with their
>> number of rows...
>>  
>> give me query
>> thankz
>>

> select table_name, num_rows
> from user_tables
> order by 1;
>
> gives tables of the current user.
>
> --
> Arto Viitanen
> Espoo, Finland
Received on Wed Dec 07 2005 - 04:12:39 CST

Original text of this message

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