RE: How to get the count of all tables using dbms_sql
If the database is 8i+, you can try 'EXECUTE IMMEDIATE' command. Does make life somewhat simpler. Regards, Charu -Original Message- Ling Catherine (CSC) Sent: Thursday, October 17, 2002 3:25 PM To: Multiple recipients of list ORACLE-L Hi, I've found the answer. DECLARE countval NUMBER; curidBINARY_INTEGER; retval NUMBER; BEGIN for i in (select OWNER,TABLE_NAME from DBA_TABLES WHERE ROWNUM) loop curid:= dbms_sql.open_cursor; dbms_sql.parse( curid, 'BEGIN SELECT count(*) INTO :cntval FROM '|| i.owner||'.'||i.table_name||'; END;', dbms_sql.v7 ); dbms_sql.bind_variable( curid, 'cntval', countval ); retval:= dbms_sql.execute( curid ); dbms_sql.variable_value( curid, 'cntval', countval ); dbms_sql.close_cursor( curid ); dbms_output.put_line( 'Count is:= ' || countval ); end loop; END; / Regds, New Bee -Original Message- From: CHAN Chor Ling Catherine (CSC) Sent: Thursday, October 17, 2002 4:12 PM To: '[EMAIL PROTECTED]' 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: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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). * Disclaimer This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. * Visit us at http://www.mahindrabt.com -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Charu Joshi INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).
RE: How to get the count of all tables using dbms_sql
Hi, I've found the answer. DECLARE countval NUMBER; curidBINARY_INTEGER; retval NUMBER; BEGIN for i in (select OWNER,TABLE_NAME from DBA_TABLES WHERE ROWNUM) loop curid:= dbms_sql.open_cursor; dbms_sql.parse( curid, 'BEGIN SELECT count(*) INTO :cntval FROM '|| i.owner||'.'||i.table_name||'; END;', dbms_sql.v7 ); dbms_sql.bind_variable( curid, 'cntval', countval ); retval:= dbms_sql.execute( curid ); dbms_sql.variable_value( curid, 'cntval', countval ); dbms_sql.close_cursor( curid ); dbms_output.put_line( 'Count is:= ' || countval ); end loop; END; / Regds, New Bee -Original Message- From: CHAN Chor Ling Catherine (CSC) Sent: Thursday, October 17, 2002 4:12 PM To: '[EMAIL PROTECTED]' 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: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).
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@;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: [EMAIL PROTECTED] > > 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: [EMAIL PROTECTED] (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). > * This e-mail message, and any files transmitted with it, are confidential and intended solely for the use of the addressee. If this message was not addressed to you, you have received it in error and any copying, distribution or other use of any part of it is strictly prohibited. Any views or opinions presented are solely those of the sender and do not necessarily represent those of the British Geological Survey. The security of e-mail communication cannot be guaranteed and the BGS accepts no liability for claims arising as a result of the use of this medium to transmit messages from or to the BGS. The BGS cannot accept any responsibility for viruses, so please scan all attachments.http://www.bgs.ac.uk * -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Robson, Peter INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).
Re: How to get the count of all tables using dbms_sql
"CHAN Chor Ling Catherine (CSC)" wrote: > > 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 > -- Read DBMSQL.SQL (under $ORACLE_HOME/rdbms/admin), you have examples in the comments. -- Regards, Stephane Faroult Oriole Software -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stephane Faroult INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).