Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to get the count of all tables using dbms_sql
Its just possible that the script I presented at UK-OUG two years ago may
meet your requirements. It uses nested SQL*Plus (not pl/sql) to count as
many tables as you identify in a driver table, and store those results.
Check it out at http://peter-robson.port5.com/count.htm
The site will be subject to some modifications over the next couple of months, but most of the stuff is there.
peter
edinburgh
> -----Original Message-----
> From: CHAN Chor Ling Catherine (CSC) [mailto:clchan_at_nie.edu.sg]
> Sent: 17 October 2002 10:19
> To: Multiple recipients of list ORACLE-L
> Subject: How to get the count of all tables using dbms_sql
>
>
> Hi,
>
> I need to insert the total number of records all the tables
> into the table,
> MIGRATION_TABLE. I want to use the
> How do I obtain the count(*) into a variable in
> "dbms_sql.parse(cid, 'SELECT
> COUNT(*) FROM ' ||i.owner||'.'||i.table_name, dbms_sql.v7); " ?
>
> TIA
>
> Declare
> cid INTEGER;
> BEGIN
> for i in (select OWNER,TABLE_NAME from DBA_TABLES) loop
>
> -- Open new cursor and return cursor ID.
> cid := dbms_sql.open_cursor;
>
> /* Parse and immediately execute dynamic SQL statement built by
> concatenating table name to DROP TABLE command. (Unlike DML
> statements, DDL statements are executed at parse time.) */
> dbms_sql.parse(cid, 'SELECT COUNT(*) FROM '
> ||i.owner||'.'||i.table_name,
> dbms_sql.v7);
>
> /* Close cursor. */
> dbms_sql.close_cursor(cid);
>
> end loop;
>
> EXCEPTION
> /* If an exception is raised, close cursor before exiting. */
> WHEN OTHERS THEN
> dbms_sql.close_cursor(cid);
> END;
>
> Regds,
> New Bee
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: CHAN Chor Ling Catherine (CSC)
> INET: clchan_at_nie.edu.sg
>
> Fat City Network Services -- 858-538-5051 http://www.fatcity.com
> San Diego, California -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
scan all attachments. http://www.bgs.ac.uk *********************************************************************
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Robson, Peter INET: pgro_at_bgs.ac.uk Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Thu Oct 17 2002 - 06:18:46 CDT