Oracle Discussions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prabhat Kumar
    New Member
    • Feb 2007
    • 1

    Oracle Discussions

    I would like to fetch all table rows count. I am using these strategy -
    Create a Cursor to fetch all table name and read one by one. and this fetched result i will send it select statement, but my select statement does not recognize table name. How i achive this result.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Prabhat Kumar
    I would like to fetch all table rows count. I am using these strategy -
    Create a Cursor to fetch all table name and read one by one. and this fetched result i will send it select statement, but my select statement does not recognize table name. How i achive this result.
    show me thy qry

    Comment

    • rectoverso
      New Member
      • Mar 2007
      • 16

      #3
      Originally posted by vijaydiwakar
      show me thy qry

      you can do it using dynamic sql in the procedure
      declare
      i number := 0;
      j number := 0;
      begin
      for c in ( select table_name from user_tables ) loop
      execute immediate ' select count(*) from '||c.table_name into i;
      j := j + 1;
      end loop;
      dbms_output.put _line(' my total count is '||j);
      end;

      Comment

      • rectoverso
        New Member
        • Mar 2007
        • 16

        #4
        Originally posted by rectoverso
        you can do it using dynamic sql in the procedure
        declare
        i number := 0;
        j number := 0;
        begin
        for c in ( select table_name from user_tables ) loop
        execute immediate ' select count(*) from '||c.table_name into i;
        j := j + 1;
        end loop;
        dbms_output.put _line(' my total count is '||j);
        end;
        excuse

        the script is

        declare
        i number := 0;
        j number := 0;
        begin
        for c in ( select table_name from user_tables ) loop
        execute immediate ' select count(*) from '||c.table_name into i;
        j := j + i;
        end loop;
        dbms_output.put _line(' my total count is '||j);
        end;

        Comment

        Working...