Re: 'Simple' Function or Procedure w/SELECT
Date: Wed, 1 Jun 1994 19:39:35 GMT
Message-ID: <MLOENNRO.94Jun1213935_at_ramses.se.oracle.com>
In article <sreiss.24.2DEBC7F2_at_wpo.borland.com> sreiss_at_wpo.borland.com (Steve Reiss) writes:
>
> All,
>
> I'm trying to write a very simple (I hope) function or procedure that when
> passed a table name or search criteria, it will return a value such as the
> number of records in the table, or the entire row. This would be the result
> of a SELECT statement. Or put another way, a function that returns the all
> the rows that meet a condition.
>
> I've tried w/o success to create a CountRec function. I get a number of
> errors and can't proceed:
>
>
> CREATE FUNCTION CountRec(tblName VARCHAR2) RETURN NUMBER
> IS CURSOR CNT_CURSOR IS
>
> SELECT COUNT(*) FROM tblName;
>
In Oracle v7.1 we will be supplying a dynamic-SQL package enabling you to use something resembling dynamic SQL method 4 in Pro*C from within PL/SQL. You can get rowcount of all of your tables with SQLPLUS:
set termout off feedback off pagesize 0
spool count.sql
select 'select ''' || table_name || ''', count(1) from ' ||
table_name || ';'
from user_tables;
spool off
_at_count
Hope this helps...
-- Magnus Lonnroth Tech.Sales & Consultant Oracle Sweden Mail: mloennro_at_se.oracle.comReceived on Wed Jun 01 1994 - 21:39:35 CEST