Count number of rows in table

Hi!
1. How can you through ABAP and select statements count the number of rows in one table?
2. I want to read all rows from one table to an internal table. Can this be done dynamically or do I first have to count the number of rows in the table and then declare an internal table with the number of rows counted.
regards
Baran

HI,
No you don't have to count number of rows first, Internal table size will increase dynamically. you have to declare this with initial size like this.
<b>data: itab type standard table of bkpf initial size 0.
SELECT * FROM bkpf into table itab.</b>
All values from bkpf will be inserted into table internal table itab.
Regards,

Similar Messages

  • How to count number of rows in table

    can I get number of row in table except Count(*) in pl/sql
    is there any other way

    Also posted and answered here
    how to count number of rows in table
    count(*) will be the fastest way. It is only slow if the table has a vast number of rows, in which case why do you need to know the tables has 73552436467721 rows and not 73552436467737 rows. It doesn't seem to be much use. Either that or you are counting them a lot, which again seems rather pointless.

  • How to add the Row count(number of rows in table)  in  the table header?

    Hi,
    I'm having a table. This table is viewed when i click on a search button.
    <b>On the table header it should dynamically display the number of rows in the table, i.e., the row count.</b>
    How to do this? could any one explain me with the detailed procedure to achieve this.
    Thanks & Regards,
    Suresh

    If you want to show a localized text in the table header, you should use the <b>Message Pool</b> to create a (parameterized) message "tableHeaderText" like "There are table entries".
    Next, create a context attribute "tableHeaderText" of type "string" and bind the "text" property of the table header Caption UI element to this attribute.
    Whenever the table data has changed (e.g. at the end of the supply function for the table's data source node), update the header text:
    int numRows = wdContext.node<TableDataSourceNode>().size();
    String text = wdComponentAPI.getTextAccessor().getText
      IMessage<ComponentName>.TABLE_HEADER_TEXT,
      new Object[] { String.valueOf(numRows) }
    wdContext.currentContextElement().setTableHeaderText(text);
    Maybe you want to provide a separate message for the case that there are no entries.
    Alternatively, you can make the attribute calculated and return the header text in the attribute getter.
    Armin

  • Is it possible to show the count of number or rows in table on the Home page Tab button.

    Is it possible to show the count of number or rows in table on the Home page Tab button.
    On home page there is a Tab called Count and I want to show the count on the right corner of this tab button.
    Please help

    Create an application item. APP_HOME_COUNT.
    Create an application process:
      make the application process type "on new instance" if you only want this to run once
      make it "on load before header" if you want to have the value set every page load
    application process source:
    select count(*) into APP_HOME_COUNT from <your table>
    modify the tab name to reference the app item, maybe something like "Count(&APP_HOME_COUNT.)"
    result should look like this "Count(5)"
    Good Luck,
    Tyson

  • Need help to count number of rows and display in file

    Hello,
    my scenario is IDOC to File......i am using XSLT mapping and using FCC parameters to convert the flat file.
    now new requirement is i need to count number of rows and add count value last of the file.
    Please let me know how to do it,
    thanks in advance for your help.
    Regards,
    Chinna

    thanks again, one more Q.
    in XSLT mapping i have written for loop for complete structure.
    example : <Details>
                         <node1>
                         <node2>
                   </details>
    in XSLT mapping
                         <xsl:for-each select="ZMATMAS_01/IDOC/E1MARAM">
         <Details>
         </Details>
         </xsl:for-each>
    if i add the field at target side....then i will come under details node and it will be repeated.
    how to declare in XSLT mapping.

  • Searchin pattern in datbase table.(Number of rows in table :More than 3 cro

    Actually i have a db table having 2 columns(columnA,time).db table has 70lac rows.I have to retireve all those values which are present min. 2 times in the interval of 10 minutes for a particular value of columnA. eg. columnA,time values are
    {a,June-01-2011 10:13:12},{b,June-01-2011 10:14:12},{b,June-01-2011 10:15:12},{c,June-01-2011 10:16:12},{b,June-01-2011 10:17:12},{d,June-01-2011 10:18:12},{d,June-01-2011 10:25:12},{e,June-01-2011 10:26:12},{e,June-01-2011 11:38:12},{f,June-01-2011 10:39:12},{f,June-01-2011 10:43:12},{a,June-01-2011 10:44:12},{f,June-01-2011 10:51:12},{b,June-01-2011 10:51:12},{b,June-01-2011 10:53:12},{c,June-01-2011 10:54:12},{g,June-01-2011 10:55:12},{b,June-01-2011 10:56:12},{b,June-01-2011 10:57:12},{b,June-01-2011 10:58:12}
    Then I have to retrieve following rows in output : {b,June-01-2011 10:14:12},{b,June-01-2011 10:15:12},{b,June-01-2011 10:17:12},{d,June-01-2011 10:18:12},{d,June-01-2011 10:25:12},{f,June-01-2011 10:39:12},{f,June-01-2011 10:43:12},{b,June-01-2011 10:51:12},{b,June-01-2011 10:53:12},{b,June-01-2011 10:56:12},{b,June-01-2011 10:57:12},{b,June-01-2011 10:58:12}
    Is it related to data Mining? i have 3 crore rows in database table.I have to search such type of many patterns in my application.I have spent hours looking for tutorials on Google. However I cannot seem to find anything that holds the hand? try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic. Can oracle java data mining solve the problem?

    first of all thanks for reply, i will take care of your suggestion.
    Number of rows in table : More than 3*10pow7(30 Milion rows)(But it can be more than 120 milion)
    Actually i have to display all those rows which setisfy following criteria:( Specific value of column A should appear min 2 times in the interval of 10 minutes.)
    for eg.
    eg 1. {b,June-01-2011 10:14:12},{b,June-01-2011 10:15:12},{b,June-01-2011 10:17:12}{This set is appearing 3 times in the any interval of 10 minutes.}
    EG2 {a,June-01-2011 10:13:12} is present only one time,so i dont want this rows in output.
    EG# {e,June-01-2011 10:26:12},{e,June-01-2011 11:38:12} is present 2 times in db,but not in the interval of 10 minutes,so i dont want this rows as output.(t1=10:26:12,t2=11:38:12 difference is more than 10 minutes.)
    In my eg. i specified only 2 columns but in actual scenario there will be 8-10 columns in table.This is only one pattern which i specified,but there are many more pattern which i have to search in db.As specified above in eg. was only one pattern,After fulfiling this pattern It has to pass many other pattern.and i want result should be retrieved very fast.
    Please dont go into answer of above eg.Actually i want, what should be approach of such type of problems?
    Is this problem related to oracle data mining and how?
    Can data mining algorthms(Minimum Description Length ,Naive Bayes,Apriori,Decision Tree,Non-Negative Matrix Factorization ,Support Vector Machine...etc..) solve my problem?
    Different-2 type of queries will be fired against this table?
    if i am still not clear then let me know.

  • Can we find the number of rows in table from the dump file

    Hi All,
    Can we find the number of rows in table from the dump file with out importing the table in to the database?
    Please let me know ,if any option is there.
    Thanks,
    Kumar.

    <s>Try to import with option SHOW=Y, that should skip the number of rows which are into a table from a dump file.</s><br>
    <br>
    Nicolas.<br>
    Oops, sorry, that doesn't show the number of lines...<br>
    Message was edited by: <br>
    N. Gasparotto

  • How to set total number of rows of table control

    Hi All,
    I want to set the total number of rows of table control. I don't want to display the blank rows in table.
    Regards,
    Shrinivas

    Need some fine tuning regarding the scrollbar height but it's a start
    Unless this isn't what you asked for
    Small number of rows
    Large number of rows
    Attachments:
    PlayingWithTable.vi ‏17 KB

  • Count number of rows in a table

    Hi,
    I have a requirement. I want to frame a SQL, which takes schema name as input and returns tables owned by that schema and number of rows inside a particular table.
    A Sample output:
    ===========
    Table            No. of Rows
    ~~~~          ~~~~~~~~
    A                    123
    B                    126
    C                    234
    .Can somebody help me in framing a query for the same.
    Regards,

    hoek wrote:
    But you could use this script:
    http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
    Laurent's solution most likely was published before IOT. Anyway, IOT ovwerflow tables must be excluded. Otherwise:
    SQL> select  table_name,
      2          to_number(
      3                    extractvalue(
      4                                 xmltype(
      5                                         dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)),'/ROWSET/ROW/C')) cou
      6    from  dba_tables
      7    where owner = 'OE'
      8  /
    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
    no rows selected
    SQL> select  table_name,
      2          to_number(
      3                    extractvalue(
      4                                 xmltype(
      5                                         dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)),'/ROWSET/ROW/C')) count
      6    from  dba_tables
      7    where owner = 'OE'
      8      and nvl(iot_type,'X') != 'IOT_OVERFLOW'
      9  /
    TABLE_NAME                          COUNT
    CUSTOMERS                             319
    WAREHOUSES                              9
    ORDER_ITEMS                           665
    ORDERS                                105
    INVENTORIES                          1112
    PRODUCT_INFORMATION                   288
    PRODUCT_DESCRIPTIONS                 8640
    PROMOTIONS                              2
    PRODUCT_REF_LIST_NESTEDTAB            288
    SUBCATEGORY_REF_LIST_NESTEDTAB         21
    10 rows selected.
    SQL>  SY.

  • How to find number of rows in tables

    Hi,
    Can you please help me how to know the number of rows in all the tables databsae.
    Thanks In Advance,

    Just found out that the behaviour changed in 11.2.0.2:
    SQL> select * from v$version where rownum = 1
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production         
    1 row selected.
    SQL> select owner, table_name, column_value cnt
      from (select owner, table_name, 'count(ora:view("' || owner || '","' || table_name || '"))' xq
              from all_tables
             where table_name in ('EMP', 'DEPT')),
           xmltable (xq) order by owner, table_name desc
    OWNER                          TABLE_NAME                     CNT  
    FLEET                          EMP                            14   
    FLEET                          DEPT                           4    
    MICHAEL                        EMP                            14   
    MICHAEL                        DEPT                           5    
    SCOTT                          EMP                            14   
    SCOTT                          DEPT                           4    
    STEFAN                         EMP                            14   
    STEFAN                         DEPT                           4    
    8 rows selected.

  • Count number of rows

    is there a more elegant way to count the number of rows in a table. Only way I can think is to make a hidden column populated with the row numbers and then use a max function.
    thanks

    Thanks Yven - just the ticket.
    PW your suggestion was useful as I didnt know about the COUNTA function.
    I have a table that takes all it values via an Index calculation from a master table (selected by a check mark or number). As such it is possible to have more selected in the master list than rows are available in the View table. I can now add a warning that tells me more values have been selected than can be presented.
    I actually have four tables each representing a song set list for a performance and the master table is the complete list of songs to choose from. The reality is the size of the table isnt likely to change so I probably could use a fixed value but I always like to be flexible.
    The system works OK as I can drag the songs into different orders but gets a little messed up if I change the sort order of the master or add new entries. and if I decide a song needs to be in another set I have to go back to the master to change the cat code.
    I often think this would be a good idea for a piece of software especially when touch pads and screen become more popular. There is a nice little list software that demoed the iPhone capabilites in this idea.

  • Count number of rows from oracle and sql database and generate a report

    Hi All,
    Can someone help me in writing a java program for the following scenario?
    1. Read the number of rows available from oracle table and print the total row count in a Report.txt text file.
    2. Read the number of rows inserted in a sql database (after a specific process-just an information) and print the total row count in the same text file Report.txt .
    3. Read the Error Log file (which is generated after a specific process say it has success and failed report for each iterations) and print the number of success and number of failure in the same text file Report.txt .
    I need the final Report.txt file in the following format:
    1. Oracle table <table name> has 500000 rows.
    2. After completion of the specific process 300000 rows were added to SQL table <table name>
    Error Log Report:
    300000 successfull entries and 200000 failed entries were found from the Error Log file.

    Thanks for your immediate reply.
    I'm just a beginner in java so if i make any mistake please correct and excuse me. :)
    This is the code i have for connecting to two different database.
    package connectDatabase;
    * @author
    import java.sql.*;
    public class ConnectTo
         public void OracleDB()
              Connection dbconn;
              try {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                String connString="jdbc:oracle:thin:@SYS_IP:1521:oracl";
                dbconn = DriverManager.getConnection(connString, "uname","pwd" );
            catch(SQLException sqlex)
                 sqlex.printStackTrace();
            catch(Exception excp)
                excp.printStackTrace();
         public void SqlDB()
              Connection conn;
              try { 
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
                String url = "jdbc:odbc:connectDB"; 
                conn = DriverManager.getConnection(url,"uname","pwd");  
              catch (Exception e)
                System.err.println("An Exception occured! " +e.getMessage()); 
    }I'm just codding the second half which is for connecting to oracle databse and calculates the row count and displayes in the command prompt.
    then connects to SQL database and counts successfull insert in the table.(row count) and displayes on the command prompt.
    can you simplify the above code so that i can call the oracleDB() method and SqlDB() method seperately from another calss file using the object of this class?
    I'm ok if the report can be seen in a command prompt. FInally i need to calculate the success and failure count from the log file. will let you know once i'm done with codding.

  • Auto Counting Number of Rows Where Data is Entered

    I am trying to automatically count the number of rows where data is entered.  For example, I have a table with six open rows to enter information.  If only three of those rows (A2-A4) had names entered in them, and the next three rows were left blank, can I get each name to equal the value "1" so that I can get a total tally of how many names have been entered? So the final tally in this example would be "3." I appreciate your help!
    file:///Users/josephdlugo/Desktop/Screen%20Shot%202014-04-30%20at%2011.58.28%20A M.png

    there is a function, COUNTA(), that will count the number of items that are not empty:
    C1=COUNTA(B)
    this is shorthand for select cell C1, then type, or copy and paste the formula:
    =COUNTA(B)
    The COUNTA function returns the number of its arguments that are not empty.
    COUNTA(value, value…)
    value: Any value or a collectioncontaining any values.
    value…: Optionally include one or more additional values or collections.

  • How to count number of rows as well as the sum of a column in a procedure

    Hi, i need to count the number of rows a sql returns in a procedure.
    as well as i need to sum up a different column.
    i need the following output:
    count the number of rows output
    and sum the total column
    code:
    procedure samba_extraction (p_errmsg IN out varchar2
    ,p_errcode IN out NUMBER
    ,p_filename in varchar2
    ,p_start_date varchar2
    ,p_end_date varchar2)
    is
    file_handle utl_file.file_type; -- file handle of os flat file
    -- cursor to select the c_samba_resources
    cursor c_samba is
    select
    lpad(h.contract_number,15,'0') contract_number
    ,h.short_description description
    ,h.attribute_category context_value
    ,h.attribute7 samba
    ,h.attribute8 samba_number
    ,h.start_date start_date
    ,h.end_date end_date
    ,h.sts_code active_inactive
    ,l.price_negotiated price
    ,l.tax_amount tax
    ,LTRIM(to_char((l.price_negotiated + l.tax_amount),'00000000.00')) total
    from
    oks_auth_headers_v h
    ,oks_auth_lines_v l
    where h.id = l.chr_id
    and ((h.start_date <= (p_end_date))
    and (h.end_date >= (p_start_date)))
    and h.attribute7 = 'SAMBA'
    -- and h.sts_code = 'ACTIVE'
    and ((h.attribute_category = 'SUBSCRIPTION.DURATION')
    or (h.attribute_category = 'SUBSCRIPTION.VALUE')
    or (h.attribute_category ='SUBSCRIPTION.QUANTITY'));
    l_output varchar2(1000);
    l_counter varchar2(11);
    l_total varchar2(11);
    l_filename varchar2(30);
    begin
    if p_filename IS NOT NULL then
    -- l_batch_no := 'T';
    l_filename := p_filename || '.txt';
    -- open file to write into and obtain its file_handle.
    file_handle := utl_file.fopen('/usr/tmp',l_filename,'W');
    fnd_file.put_line(fnd_file.log,'The '|| l_filename||' file you have requested has been placed in the usr/tmp directory');
    for l_info in c_samba
    loop
    -- l_output := null;
    l_output := l_info.samba_number||'+'||l_info.total||l_info.contract_number;
    utl_file.put_line(file_handle,l_output);
    fnd_file.put_line(fnd_file.output, l_output);
    dbms_output.put_line(l_output);
    end loop;
    else
    p_errmsg := ('Please enter a filename for this file ');
    write_log('UPDATE : ' ||p_errmsg);
    end if;
    -- close the file.
    utl_file.fclose(file_handle);
    exception
    when no_data_found then
    dbms_output.put_line('no_data_found');
    utl_file.fclose(file_handle);
    when utl_file.invalid_path then
    dbms_output.put_line('UTL_FILE.INVALID_PATH');
    utl_file.fclose(file_handle);
    when utl_file.read_error then
    dbms_output.put_line(' UTL_FILE.READ_ERROR');
    utl_file.fclose(file_handle);
    when utl_file.write_error then
    dbms_output.put_line('UTL_FILE.WRITE_ERROR');
    utl_file.fclose(file_handle);
    when others then
    dbms_output.put_line('other stuff');
    utl_file.fclose(file_handle);
    end samba_extraction;
    end xx_samba;

    Hi,
    Initialise one variable TOT_ROWS to 0.
    Then in the for loop
    tot_rows := tot_rows + +1 ;
    so after for loop the value in the tot_rows will be the total records..
    If u want it to get this value in the calling procedure of this , just declare tot_rows parameter as out parameter.
    For sum of a column:
    Initialise a variable sum_col to 0.
    In the for loop
    sum_col := sum_col+I_info.column_name
    aprameter if u wish return this value as out..
    I think this wil give u the o/p..
    cheers,
    Sivarama

  • How to count number of rows in a cursor???

    I have a cursor and i want to check number of row fetched...But not through rowcount... bcoz it will give after fetching all the rows..
    I want to get count as soon as i open the cursor..plz let me know

    David_Aldridge wrote:
    hmmm ... you'd have to wrap the query in an inline view and apply the count(*) over() in the main query I guess.Still will not cover all cases:
    Session 1:
    update emp set deptno = deptno where deptno = 20
    5 rows updated.
    SQL> Session 2:
    select  ename,
            count(*) over()
      from  emp
      for update
      skip locked
    ENAME      COUNT(*)OVER()
    ALLEN                  14
    WARD                   14
    MARTIN                 14
    BLAKE                  14
    CLARK                  14
    KING                   14
    TURNER                 14
    JAMES                  14
    MILLER                 14
    9 rows selected.Now try to wrap the above query in an inline view :).
    SY.

Maybe you are looking for

  • Unable to expand volume on array

    I've got a Mac Pro (Early 2008, 8x2.8Ghz, 6GB memory) with a Highpoint RocketRaid 3522 card in it. I started out with a raid 5 array of 3 1TB WD GreenPower drives in a SuperMicro CSE-M35T-1B sata cage. Partitioned it as GUID HFS+ (1.8TB) and it works

  • Which wireless router should I buy?

    After many hassles trying to get my 3 yr old speedtouch router to work reliably with my Macs I've decided it's time for an upgrade. Can I please get your wireless router recommendations for hassle free surfing on a Mac Many thanks David

  • All of the App Tabs I have set when I quite Firefox did not open as App Tabs when you start Firefox again, why?

    All the App Tabs disappeared when I opened Firefox after quitting. I understand that the App Tabs that I had set remains there if I close the browser and not quit. So does that mean that I have to create App Tabs every time I restart FireFox?

  • ITunes 7 wont have store load

    The Music Store will not load with iTunes 7. Any ideas why?

  • E65 Buttons not working, phone locking up.

    So this afternoon all of a sudden I couldn't make any calls, the send and end buttons are making the phone beep but that's about it. Turned it off and on a few times. It worked to make one call then did it again. So then I tried making a call by sele