<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How do i store the counts of all tables &#8230;</title>
	<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html</link>
	<description>Oracle Certified Master</description>
	<pubDate>Sat, 17 May 2008 19:56:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Brian Tkatch</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6505</link>
		<pubDate>Tue, 29 Apr 2008 14:14:13 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6505</guid>
					<description>Just got to this from the forums.

Laurent, that is fantastic.</description>
		<content:encoded><![CDATA[<p>Just got to this from the forums.</p>
<p>Laurent, that is fantastic.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6301</link>
		<pubDate>Thu, 24 Apr 2008 16:43:01 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6301</guid>
					<description>did you check my former comment about a plsql solution?</description>
		<content:encoded><![CDATA[<p>did you check my former comment about a plsql solution?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: steven zydek</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6296</link>
		<pubDate>Thu, 24 Apr 2008 16:20:04 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-6296</guid>
					<description>This is my version w/o the cool XML stuff that Laurent has. This pretty much just dumps out all non SYS-owned tables from dba_objects and has error handling for TABLEs that can't be counted (i.e., the IOT exception). Let me know your thoughts. This is crude at the moment, but you get the idea.

set serveroutput on
declare
 type tablename is table of dba_objects.object_name%type
         index by binary_integer;
    table_list tablename;
    indx  number := 0;
    v_count number := 0;
    v_tab varchar2(256);
    v_sqltext varchar2(1000);
  begin
    for r_c3 in (select owner,object_name from dba_objects where object_type = 'TABLE') loop
      table_list(indx) := r_c3.owner&#124;&#124;'."'&#124;&#124;r_c3.object_name&#124;&#124;'"';
      indx := indx + 1;
    end loop;
    for xndx in table_list.first..table_list.last loop
      if table_list.exists(xndx) 
        and table_list(xndx) not like 'SYS.%' then
        v_tab := table_list(xndx);
        v_sqltext := 'select count(*) from '&#124;&#124; table_list(xndx);
        -- dbms_output.put_line(v_sqltext);
        BEGIN
        execute immediate v_sqltext into v_count;
        dbms_output.put_line(table_list(xndx) &#124;&#124; ', ' &#124;&#124; v_count);
        exception when OTHERS then dbms_output.put_line(table_list(xndx) &#124;&#124; ', NULL');
        END;
      end if;
    end loop;
  end;
/</description>
		<content:encoded><![CDATA[<p>This is my version w/o the cool XML stuff that Laurent has. This pretty much just dumps out all non SYS-owned tables from dba_objects and has error handling for TABLEs that can&#8217;t be counted (i.e., the IOT exception). Let me know your thoughts. This is crude at the moment, but you get the idea.</p>
<p>set serveroutput on<br />
declare<br />
 type tablename is table of dba_objects.object_name%type<br />
         index by binary_integer;<br />
    table_list tablename;<br />
    indx  number := 0;<br />
    v_count number := 0;<br />
    v_tab varchar2(256);<br />
    v_sqltext varchar2(1000);<br />
  begin<br />
    for r_c3 in (select owner,object_name from dba_objects where object_type = &#8216;TABLE&#8217;) loop<br />
      table_list(indx) := r_c3.owner||&#8217;.&#8221;&#8216;||r_c3.object_name||&#8217;&#8221;&#8216;;<br />
      indx := indx + 1;<br />
    end loop;<br />
    for xndx in table_list.first..table_list.last loop<br />
      if table_list.exists(xndx)<br />
        and table_list(xndx) not like &#8216;SYS.%&#8217; then<br />
        v_tab := table_list(xndx);<br />
        v_sqltext := &#8217;select count(*) from &#8216;|| table_list(xndx);<br />
        &#8212; dbms_output.put_line(v_sqltext);<br />
        BEGIN<br />
        execute immediate v_sqltext into v_count;<br />
        dbms_output.put_line(table_list(xndx) || &#8216;, &#8216; || v_count);<br />
        exception when OTHERS then dbms_output.put_line(table_list(xndx) || &#8216;, NULL&#8217;);<br />
        END;<br />
      end if;<br />
    end loop;<br />
  end;<br />
/
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Saji Alexander</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-2235</link>
		<pubDate>Mon, 07 May 2007 13:59:58 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-2235</guid>
					<description>Simply Great.</description>
		<content:encoded><![CDATA[<p>Simply Great.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Marco Gralike</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-2179</link>
		<pubDate>Thu, 03 May 2007 06:55:11 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-2179</guid>
					<description>The scalar problem can be surpassed by using extract (object_value,'/ROWSET/ROW/C/text()'). A disadvantage of both is that the performance will degrade due to DOM validation, BUT...

GREAT EXAMPLE Laurent. I love it!

Grz

Marco</description>
		<content:encoded><![CDATA[<p>The scalar problem can be surpassed by using extract (object_value,&#8217;/ROWSET/ROW/C/text()&#8217;). A disadvantage of both is that the performance will degrade due to DOM validation, BUT&#8230;</p>
<p>GREAT EXAMPLE Laurent. I love it!</p>
<p>Grz</p>
<p>Marco
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Vadim Tropashko</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1927</link>
		<pubDate>Wed, 25 Apr 2007 21:45:45 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1927</guid>
					<description>Mine was a minor comment, really:-) As you may have noticed, I'm on my anti-cursor crusade. Much more important is the idea summarized by "No XML!" emblem at my home page...</description>
		<content:encoded><![CDATA[<p>Mine was a minor comment, really:-) As you may have noticed, I&#8217;m on my anti-cursor crusade. Much more important is the idea summarized by &#8220;No XML!&#8221; emblem at my home page&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: laurentschneider</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1871</link>
		<pubDate>Tue, 24 Apr 2007 07:51:00 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1871</guid>
					<description>thanks vadim, &lt;i&gt;execute immediate 'select ...' into&lt;/i&gt; is easier and cleaner than my &lt;i&gt;refcursor&lt;/i&gt;</description>
		<content:encoded><![CDATA[<p>thanks vadim, <i>execute immediate &#8217;select &#8230;&#8217; into</i> is easier and cleaner than my <i>refcursor</i>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Vadim Tropashko</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1863</link>
		<pubDate>Tue, 24 Apr 2007 00:42:15 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1863</guid>
					<description>Opps, your function is scalar which is simpler than table function. What I meant was that no cursor is necessary:

create or replace function count_rows(table_name varchar2)
return varchar2 is
i number;
begin
execute immediate 'select count(*) c from '&#124;&#124;table_name into i;
return i;
end;
/


select count_rows(table_name) from user_tables;</description>
		<content:encoded><![CDATA[<p>Opps, your function is scalar which is simpler than table function. What I meant was that no cursor is necessary:</p>
<p>create or replace function count_rows(table_name varchar2)<br />
return varchar2 is<br />
i number;<br />
begin<br />
execute immediate &#8217;select count(*) c from &#8216;||table_name into i;<br />
return i;<br />
end;<br />
/</p>
<p>select count_rows(table_name) from user_tables;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Vadim Tropashko</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1861</link>
		<pubDate>Tue, 24 Apr 2007 00:34:12 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1861</guid>
					<description>Wouldn't table function solution cleaner than cursor? (I'm not even considering XML solution as a contender).</description>
		<content:encoded><![CDATA[<p>Wouldn&#8217;t table function solution cleaner than cursor? (I&#8217;m not even considering XML solution as a contender).
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Coskan</title>
		<link>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1820</link>
		<pubDate>Thu, 19 Apr 2007 13:34:30 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html#comment-1820</guid>
					<description>It is so cool but does not work for IOT :(

SYS@XE&#62; select
  2     table_name,
  3     to_number(
  4       extractvalue(
  5         xmltype(
  6      dbms_xmlgen.getxml('select count(*) c from '&#124;&#124;table_name))
  7         ,'/ROWSET/ROW/C')) count
  8   from user_tables;
ERROR:
ORA-19202: Error occurred in XML processing
ORA-25191: cannot reference overflow table of an index-organized table
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1</description>
		<content:encoded><![CDATA[<p>It is so cool but does not work for IOT <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><a href="mailto:SYS@XE&gt;">SYS@XE&gt;</a> select<br />
  2     table_name,<br />
  3     to_number(<br />
  4       extractvalue(<br />
  5         xmltype(<br />
  6      dbms_xmlgen.getxml(&#8217;select count(*) c from &#8216;||table_name))<br />
  7         ,&#8217;/ROWSET/ROW/C&#8217;)) count<br />
  8   from user_tables;<br />
ERROR:<br />
ORA-19202: Error occurred in XML processing<br />
ORA-25191: cannot reference overflow table of an index-organized table<br />
ORA-06512: at &#8220;SYS.DBMS_XMLGEN&#8221;, line 176<br />
ORA-06512: at line 1
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
