Procudure to count all the rows in a all tables in the schema

When I run the following store procedure to count all the rows in all the tables I crash my sql Plus editor:
CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT(OWNER IN varchar2)
IS
row_count number;
cursor get_tab is
select table_name, num_rows
from all_tables
where owner='MAXDEV';
begin
dbms_output.put_line('Checking Record Counts for schema maxdev ');
FOR get_tab_rec IN get_tab LOOP
     BEGIN
          EXECUTE IMMEDIATE 'select count(*) from '||get_tab_rec.table_name
          INTO row_count;
          EXCEPTION WHEN OTHERS THEN
                    dbms_output.put_line('Error counting rows for table '
                                             ||get_tab_rec.table_name);
     END;
END LOOP;
END;
What am I doing wrong.
Thanks for any help Tony

The boss gave me 5 pages of tables and wants to know how many row there are in each table. There is a problem of one DB being out of sync with another.
But I have managed to work the problem though.
here is the working code:
CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT (
TableOwner IN varchar2)
IS
row_count number;
vTable varchar2(30);
v_sqlstmt varchar2(100);
cursor get_tab is
select table_name, num_rows
from all_tables
where owner = TableOwner;
begin
dbms_output.put_line('Checking Record Counts for schema maxdev ');
FOR get_tab_rec IN get_tab LOOP
vTable := get_tab_rec.table_name;
v_sqlstmt := 'SELECT count(*) from '||vTable;
EXECUTE IMMEDIATE v_sqlstmt into row_count;
dbms_output.put_line('Table '|| get_tab_rec.table_name || ' Row ' || row_count);
END LOOP;
END;

Similar Messages

  • Is it possible to resize the row / column of a table at run time ?

    Hello All ,
    I want to make a table where the user have to put datas . But if some data exceeds the length of the column / row the user should have the ability to resize the column / row of the table just like we are able to do at the time of designing . Is it possible ??
    Thanks .
    Bibhu .

    Hi,
    If you select a cell in the table that cannot receive data, then the expand to fit will not be available.
    However if you select an object that is in the table (like a textfield) then the option of expand to fit should be available.
    Try experimenting with the options.
    Niall

  • How can i know the row number of my table is being modified?

    HI all,
    I have a table in my web dynpro and several columns as checkbox... I put an event OnToggle in these columns.
    Do you know any way to get the row or the row number?
    If i use the method get_static_attributes return to me the selected row not the modified.
    Thanks in advance !

    EDIT: thanks ! is solved, i need to pass CONTEXT_ELEMENT' in the  <ELEMNT_NAME>
    This is my code:
    DATA table_element TYPE REF TO if_wd_context_element.
      DATA row_index TYPE i.
      table_element = wdevent->get_context_element('CONTEXT_ELEMENT').
      IF NOT table_element IS INITIAL.
        row_index = table_element->get_index( ).
      ENDIF.
    Edited by: Husalban RM on Sep 15, 2010 4:53 PM

  • Create an internal table with the rows of another internal table.

    Hi I want to know if posible to create an internal table structure with the  rows of another internal table?
    ex.
    If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
    Now I want that the structure of my internal table be: first, second, third

    Hi,
    If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
    Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
    Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
    Data: begin of second_table occurs 0,
    first type <first_table type>,
    second type <first_table type>,
    third type <first_table type>,
    end of second_table.
    Regards
    Prasenjit

  • How to computer the row size of a table

    Hi
    How can i compute the row size of a table. My general Idea is
    create table emp(
    empno number(4),
    ename varchar2(10),
    hire_date date,
    update_yn timestamp);
    the character set is UFT8
    how can i compute the size of this table
    thanks

    Hi,
    for Avg. row length see this
    SQL> desc dba_tables
    Name                                      Null?    Type
    OWNER                                     NOT NULL VARCHAR2(30)
    TABLE_NAME                                NOT NULL VARCHAR2(30)
    TABLESPACE_NAME                                    VARCHAR2(30)
    CLUSTER_NAME                                       VARCHAR2(30)
    IOT_NAME                                           VARCHAR2(30)
    PCT_FREE                                           NUMBER
    PCT_USED                                           NUMBER
    INI_TRANS                                          NUMBER
    MAX_TRANS                                          NUMBER
    INITIAL_EXTENT                                     NUMBER
    NEXT_EXTENT                                        NUMBER
    MIN_EXTENTS                                        NUMBER
    MAX_EXTENTS                                        NUMBER
    PCT_INCREASE                                       NUMBER
    FREELISTS                                          NUMBER
    FREELIST_GROUPS                                    NUMBER
    LOGGING                                            VARCHAR2(3)
    BACKED_UP                                          VARCHAR2(1)
    NUM_ROWS                                           NUMBER
    BLOCKS                                             NUMBER
    EMPTY_BLOCKS                                       NUMBER
    AVG_SPACE                                          NUMBER
    CHAIN_CNT                                          NUMBER
    AVG_ROW_LEN NUMBER
    AVG_SPACE_FREELIST_BLOCKS                          NUMBER
    NUM_FREELIST_BLOCKS                                NUMBER
    DEGREE                                             VARCHAR2(10)
    INSTANCES                                          VARCHAR2(10)
    CACHE                                              VARCHAR2(5)
    TABLE_LOCK                                         VARCHAR2(8)
    SAMPLE_SIZE                                        NUMBER
    LAST_ANALYZED                                      DATE
    PARTITIONED                                        VARCHAR2(3)
    IOT_TYPE                                           VARCHAR2(12)
    TEMPORARY                                          VARCHAR2(1)
    SECONDARY                                          VARCHAR2(1)
    NESTED                                             VARCHAR2(3)
    BUFFER_POOL                                        VARCHAR2(7)
    ROW_MOVEMENT                                       VARCHAR2(8)
    GLOBAL_STATS                                       VARCHAR2(3)
    USER_STATS                                         VARCHAR2(3)
    DURATION                                           VARCHAR2(15)
    SKIP_CORRUPT                                       VARCHAR2(8)
    MONITORING                                         VARCHAR2(3)
    CLUSTER_OWNER                                      VARCHAR2(30)
    DEPENDENCIES                                       VARCHAR2(8)
    SQL> Regards!

  • Fixing the height of the maon area of a table in the main window in smartfo

    hi all,
    I have a requirement where I need to fix the height of the main area of a table in the main window in a smartform.

    Hi,
    If you need to fix the height of the main area of a table on a page.
    Then use a loop node to loop the table with 1 to 6 rows and under the loop node make us of a template for displaying the fixed no of rows.
    Regards,
    Ram

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Unselect all the rows when display my table the first time

    Hi all,
    When I execute my webdynpro the first time my table is displayed with the first row selected, but this is false, this line is not selected.
    If i execute the method get_selected_elements don't return anything in the table, but if i do a Click in this row then works fine.
    I tried to unselect all the rows when i display the table the first time in the method WDDOINIT doing the following;
    DATA lo_nd_my_table TYPE REF TO if_wd_context_node.
      DATA: lt_elements TYPE wdr_context_element_set,
                 lo_element TYPE REF TO if_wd_context_element,
                 lo_node TYPE REF TO if_wd_context_node.
      lo_nd_my_table = wd_context->get_child_node( name = wd_this->wdctx_my_table ).
      lt_elements = lo_nd_my_table->get_elements( ).
      LOOP AT lt_elements INTO lo_element.
        lo_element->set_selected( SPACE ).
      ENDLOOP.
    But, doesn't work...
    How can i do it?
    Thanks in advance.

    hi,Husalban RM     .
    You don't need to DE-SELECT each element of the context node.
    You can try the following:
    lo_node->set_lead_selection_index( -1 ).
    "lo_node is the context node which is bound to your table.
    Hope it can help you a little.
    Best wishes.

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • JDeveloper 11g: How to get all the rows of a database table from applicatio

    Hello all!
    I'm developing a application with JDeveloper 11g, like subject show.
    So, I'm suppose to use some data which are in database table.
    So, I had the View Object where I want take data, to the datamodel.
    And after this, I use this next line in my serviceClass.java:
    public String method(){
            String truc = null;
            getViewName().setRangeSize(-1);
            getViewName().setRangeStart(0);
            getViewName().executeQuery();
    //I do my treatment here
    return truc
    }When the application run, it stop just before the line "getViewName().setRangeSize(-1);"
    So, I think it is the locking point.
    Someone can help me.
    Thank's
    Nystan

    Hi,
    1. You work with a application module class and not in a plain old java object? So you create a application module or only a view object?
    2. If you work with a application module class. Can you switch on a bit of logging? To set the system debug output property, open the Run/Debug/Profile page in the Project Properties dialog for your data model project. Click Edit to edit the chosen run configuration, and add following string to the Java Options field in the page.
    -Djbo.debugoutput=console -Djbo.adflogger.level=FINE
    maybe you can see the error.
    Best regards
    Martin

  • How to get the rows in a multiselect table automatically checked?

    Hi,
    I have retrieved all the rows whose job status is 'Manager'. Now i need these rows to be automatically checked when a button is clicked.
    how do i do this?
    Please reply as soon as possible.

    Hi,
    is this a new thread or is it a duplicate of http://forums.oracle.com/forums/thread.jspa?messageID=2339633
    Frank

  • How do I select a range of rows from an internal table in the debugger?

    Hi,
    I have a case where I wanted to delete a range of rows (several thousand) from an internal table using the debugger.
    It seems that rows can only be selected one at a time by selecting (clicking) on the far left side of the row.
    This is cumbersome, if not impossible when wishing to delete several thousand rows. 
    Other tools, such as Excel for example, allow for selecting a range of rows by selecting the first row and then holding the SHIFT key and selecting the last row and all rows in between will be selected.
    I can't seem to find the combination of keys that will allow this in the table (or structure) tab of the debugger.
    Is it possible to select a range of rows without having to select each row one at a time?
    Thanks for your help,
    Andy

    While it's a Table Control and should/could have a button to select all fields (or visible fields)...I don't think we can do it right now...I know it's a pain to select each row one at a time...but I don't we have any more options...
    Greetings,
    Blag.

  • Bad performance when iterating/updating the rows of a tree table

    Hello,
    we have a tree table based on a VO and EO (with transient attributes). One of the attribute is a flag.
    The VO is populated with a complex query having many thousands of rows.
    Now, when the user clicks on a parent node, all the children are updated (their flag is set to true) recursively.
    This is really really slow. It might require several minutes, while a similar update via PL/SQL on a real table would required few seconds.
    Is there any way to improve the performance? We have already applied all the tunings on both the EO and VO mentioned in Oracle Documentation, but they had almost no effect:
    - retain viewlink row set iterators
    - query hints
    - Use update batching
    The algorithm we use is the following:
        private void checkTreeNodes(JUCtrlHierNodeBinding node, Boolean check) {
            if (node == null) {
                return;
           TreeVORowImpl nodeRow = (TreeVORowImpl)node.getRow();
            if (nodeRow != null) {
                    nodeRow.setFlag(check);
            List<JUCtrlHierNodeBinding> children = null;
            if (!nodeRow.getLevel().equals("4"))  // no more than 4 levels
                children = node.getChildren();
            if (children != null) {
                for (JUCtrlHierNodeBinding _node : children) {
                    checkTreeNodes(_node, check);
        }

    Thanks for you answer.
    I am trying to move the logic in a method of the AM. But I have an exception (jdev 11.1.2.1):
        public void checkTreeNodes(TreeVORowImpl node, Boolean check, int level) {
            if (node == null)
                return;
            node.setFlag(check);
            if (level >= 4)
                return;
            Key key = new Key(new String[] { node.getId() }); // Id is the primary Key
            // By debugging via System.out.println, the code stops here:
            RowIterator rowIt = getMyVO().findByAltKey("ParentId", key , -1, false); // children have ParentId = Id
            while (rowIt.hasNext()) {
                TreeVORowImpl row = (TreeVORowImpl)rowIt.next();
                checkTreeNodes(row, check, level + 1);
        }findByAltKey gives the following exception (since it's called from the UI by getting the AM from DataControl):
    oracle.jbo.InvalidObjNameException: JBO-25005: [...]
         at oracle.adf.model.binding.DCBindingContainerState.validateStateFromString(DCBindingContainerState.java:573)
         at oracle.adf.model.binding.DCBindingContainerState.validateStateFromString(DCBindingContainerState.java:504)
         at oracle.adf.model.binding.DCBindingContainerState.validateToken(DCBindingContainerState.java:684)
    Do you see anything wrong or not efficient?
    Thanks.

  • How to get row index of data table in the while ValueChangeListener fired?

    Hi,
    i have a data table in my page, which contains various components like inputText, selectOneChoice in each row.
    i am invoking a method ValueChangeListener attribute of the selectOneChoice component. I have given the autoSubmit=true for this component.
    <tr:selectOneChoice id="ratingModelType"
    value="#{childRatio.ratingModelType}" binding="#{pageManager.form.bindRatioType}"
    valueChangeListener="#{pageManager.form.onRatingModelTypeChange}" autoSubmit="true"
    contentStyle="width:150px" required="#{!childRatio.disableChildRatioRatingModelType}"
    requiredMessageDetail="#{appBundle['error.ratingModelTypeShouldNotBeEmpty']}">
    <f:selectItems value="#{pageManager.catalog['Rating Model Type']}" />
    <tr:selectOneChoice>In that method i want to fetch the map(with all updated values) relevant to the currently modified row of the table.
    Since i am not using the selectionListener or any radio buttons in the page i am not able to get the row index of the table.
    somebody please tell me how to get the row index of the table, while ValueChangeListener fired?
    Thanks in advance.
    Subbu

    Hi niki,
    Thank you so much. With your suggestion i got the result exactly what i want.
    thanks again.
    --subbu                                                                                                                                                                                                                               

  • How to display the rows number of times by giving the column values?

    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         SELECT 'krishna' NAME,     'hyd' LOC, 1 NUM FROM DUAL )
      SELECT T.* FROM T
      CONNECT BY ROWNUM <= NUM
    Expected output:
             venkatesh            hyd      2
             venkatesh            hyd        2
             prasad                 hyd        3
             prasad                   hyd      3
             prasad                   hyd      3
             krishna           hyd       1Edited by: Nag Aswadhati on Nov 1, 2012 12:34 AM

    Nag Aswadhati wrote:
    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    Expected output:
    venkatesh            hyd      2
    venkatesh            hyd        2
    prasad                 hyd        3
    prasad                   hyd      3
    prasad                   hyd      3
    krishna           hyd       1Using Connect By:-
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         select 'krishna' name,     'hyd' loc, 1 num from dual )
      select t.name, t.loc
      from t
      connect by level <= num
             and name = prior name
             and (prior sys_guid() is not null);
    NAME      LOC
    krishna   hyd
    prasad    hyd
    prasad    hyd
    prasad    hyd
    venkatesh hyd
    venkatesh hyd
    6 rows selected

Maybe you are looking for

  • Pdf file causing archive utility to throw error

    I have a couple of pdf files which cannot be compressed without an error. Supposing that the nasty file is called foo.pdf. . In the Finder, right click on foo.pdf . Select Compress "foo.pdf" A file called foo.pdf.zip is created but an error pops up A

  • Page display resolution setting

    Many or all CS5 apps would benefit from the same kind of Page Display preferences that Acrobat Pro provides. It allows you to set page display resolution at the pixels per inch setting that will display content at true actual size (100pct viewing). B

  • Error -3259....what do i do?

    Alright, so i buy a song and then when it attempts to download a pop up comes up stating There was a problem downloading (so and so song) The network connection timed out. I have tried numerous songs, my internet is running pretty fast, i have an upd

  • Search is working fine on one server but not giving results from other servers. moss 2007?

    hi, we have multi server or wfe architecture. configured search service on one server 01, central admin is 02, and query as 03, now crawled content with hostname:port of 01. everything is fine. but now when we trying to search results its giving resu

  • Port 1099 being used by other processes ,need an alt port for RMI-Registry

    I am using port 1099 for RMI and the o/s is windows 2003. We want that the RMI registry shud automatically be started with the windows startup processes.But we found that some other processes are usoing the same port. Is there any other port which ca