Table Record Count

In PL/SQL,
for table ZXC
and numeric varaible ZXC_Record_Count
how would I determine the number of records in ZXC and pass that value to ZXC_Record_Count?
or,
what would be the syntax to get to some kind of property like ZXC.Count?
TIA,
Far Farley

If you want the completely accurate answer, you'd need to do a COUNT(*), i.e.
SELECT COUNT(*)
  INTO ZXC_Record_Count
  FROM zxcOf course, that can be rather slow. If an approximate count is acceptable and you're using the CBO and your statistics are reasonably accurate, you could do
SELECT num_rows
  INTO ZXC_Record_Count
  FROM user_tables
WHERE table_name = 'ZXC'That's more efficient, but less accurate.
Justin

Similar Messages

  • Oracle 10g - Insert in to Temporary Table - Record count mismatch between s

    We are trying insert records from a select query in to temporary table, some of the records is missing in the temporary table. The select statement is having multiple joins and union all which it little complex query. In simple terms the script contains 2 part 1st Part Insert in to temporary table 2nd part Select query with multiple joins, inline sub queries, unions and group by classes and conditions
    Eg. If we execute select statement alone it returns some count for example => 60000 After inserting into the temp table, in temp table the count is around 42000 why is the difference?
    It is simple bulk inserts... insert in to temp table select from xxx. also, there is no commit in between. The problem is all the records populated by the select statement are not inserted in to temp table. some records are not inserted.*
    Also, we had some other observation. It only happens in its 2nd execution and not its first run. Hope there might be some cache problem
    Even, we also did not believe that. We are wondering. In TOAD, we tested however at times it happens. In application jar file, after "insert in to temp select * from xxx" we take the i. record count of temp table and ii. record count of "select * from xxx" separately but both doesn't match. Match only at 1st time.
    Thank you in advance for your efforts and help.
    Shiva.

    The code looks like
    sql = "insert in to temptable select x,y,z,.... from xxx,abc,pqr..where...."; (logial but not real is very complex around 700 lines with multiple joins, inline sub queries, group by etc. )
    stmt = conn.createStatement();
    rCount= stmt.executeUpdate(sql);
    Actual issue is
    rCount = xxxx = Count(temptable) < count(select x,y,z,.... from xxx,abc,pqr..where....)
    why this diffference ? some records populated in the select but not inserted in to temp table
    Anyone can explain?

  • Doubt in internal table record count

    Hi,
    i have an internal table with 5 fields. Last field is flag. In my internal table lot many records are there. i want to count only the records with flag 'E'. How to count the total records with 'E'.
    Mohana

    Try like this,
    Data: c type i.
    Loop at itab into wa.
    if wa-flag = 'E'.
    c = c + 1.
    endif.
    Endloop.
    Write:/ 'Total records', c.
    OR
    LOOP AT itab WHERE flag = 'E'.
      c = c + 1.
    ENDLOOP.
    Edited by: Sap Fan on Apr 3, 2009 5:21 PM

  • How to compare record count of two tables?

    Hi,
    i am in need of simple sql script where i can compare two table record count.
    i have something like below:
    (select count(*) from table1) minus (select count(*) from table2)
    now the problem is if the table1 count greater then table2 count the output is fine.
    If the table2 record count is more then i am getting zero as the output.
    how can i get the difference in two tables record count?
    Thanks a lot in advance.
    --Raman.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Doing a MINUS between the counts does not yield the diff.
    e.g. if table A has 100 records and table B has 70 records then,
    SELECT count(*) FROM A
    minus
    SELECT count(*) from B
    will give 100 and not 30.
    Try this:
    SELECT (
    CASE WHEN ((select count(*) cnt from A) - (select count(*) cnt from B)) <0
    THEN ((select count(*) cnt from A) - (select count(*) cnt from B))* -1
    ELSE ((select count(*) cnt from A) - (select count(*) cnt from B)) END) Difference
    FROM dualor this is simpler
    SELECT abs(((select count(*) cnt from A) - (select count(*) cnt from B))) difference FROM dualEdited by: Caitanya on Jan 9, 2009 7:12 AM
    Applied abs function after seeing BluShadow's post :)

  • Record count in internal table

    i want to know record count for the records stored in
    internal table.
    do we have any system field to display record count?

    Hi,
    Try this:
    Data: count_lines type i.
    describe table my_table lines count_lines.
    Regards,
    Arjan

  • Query to display all records count of all tables in a schema

    Hi,
    I need to count all the records of all my tables in a certain schema and display the max amount of the record count. Do you have a script for this one??

    SQL> create function countrec(in_tab in varchar2) return number is
      2  retval number;
      3  begin
      4    execute immediate 'select count(*) from '||in_tab into retval;
      5    return retval;
      6  end;
      7  /
    Function created.
    SQL> select table_name, countrec(table_name)
      2  from tabs;
    TABLE_NAME                     COUNTREC(TABLE_NAME)
    QUERY_TOOL_DATA_COLLECTION                        5
    TEST01                                            0
    T1                                               14
    EMP                                              14
    SALGRADE                                          5
    FILES                                             0
    PROVA                                             0
    TEST                                              0
    T_MASTER                                          1
    T_CHILD                                           3
    TAB_ONE                                          30
    TAB_TWO                                          10
    A                                                 3
    B                                                 4
    C                                                 3
    D                                                 3
    BONUS                                             0
    DEPT                                              4
    18 rows selected.Max

  • Record count is double in the Fact tables when compared to Cube data!

    Hello BW Gurus,
    I have 2 question to be answered!
    1. I have a cube which consist of 3 years of data. Due to some bad data in it, I have dropped the cube data completely from fact and dim tables and did an init. from ODS. the load failed due to "No SID found for value '2000000000000000000000010' of characteristic 0MAT_PLANT". I have run a RSRV test to find if there is any inconsistency in SID's for 0MAT_PLANT but everything looks great. Considering the time span in mind to finish the load I have removed that record from PSA and re-pushed the data from PSA which was successful, however I wanted to know if anyone has come across such kind of error.
    2. The load finished successfully in the cube but the performance of the cube was very bad coz my cube request shows only 3.5 million records but when I checked in the fact table it was showing double i.e. 7 million records, which is because I deleted the failed init. request and re-pushed the data from PSA. can anyone suggest me how to overcome this I mean how to bring back my fact table records to 3.5 million?
    please advise me and thanks so much!
    Swathi.

    hi Swathi,
    1. for 0mat_plant no sid, beside rsrv, you can try rsd1, infoobject maintenance, there is menu (about 3rd from left) 'fill sid ...'.
    for infocube update, please make sure you 'delete data',
    'fact and dim...'. check again if fact table counts 0 records then you can update from ods with 'initialize'. or if you go by psa then delete data both infocube and ods (from ods to cube should sufficient).
    2. for performance, check in infocube -> manage -> performance, make sure index and statistic is green. you can create index there, also refresh the statistic.
    hope this helps.

  • Record counts of the tables in USER_TABLES

    Hello everyone.
    Please give me advice, is it possible to enumerate the tables in the USER_TABLES and in the same time to retrieve the record count in every each of them?
    To illustrate, I want something like that:
    select t.table_name,(select count(*) from t.table_name) from USER_TABLES t
    This is only for isllustration. I know that is not the way.
    Thank you in advance for your answers.

    Code could be compacted down a little...
    SQL> set serveroutput on
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    cursor cur_table_count is
      3      select table_name from user_tables order by table_name;
      4    v_cnt number;
      5  begin
      6    dbms_output.put_line('Table Name                     Record Count');
      7    dbms_output.put_line('============================== ============');
      8    for t in cur_table_count
      9    loop
    10      execute immediate 'select count(*) from '||t.table_name into v_cnt;
    11      dbms_output.put_line(RPAD(t.table_name,31)||v_cnt);
    12    end loop;
    13* end;
    SQL> /
    Table Name                     Record Count
    ============================== ============
    BONUS                          0
    DEPT                           4
    EMP                            14
    SALGRADE                       5
    PL/SQL procedure successfully completed.

  • Restrictions in Oracle Server (table size, record count ...)

    Hello,
    can somebody tell me if there are any restrictions of table size, record count, file size (apart from operation system restrictions) in Oracle 8.1.7 and 7.3.4?
    Or where can i find information? I couldn4t find anything in the generic documentation.
    Thank you in advance,
    Hubert Gilch
    SEP Logistik AG
    Ziegelstra_e 2, D-83629 Weyarn
    Tel. +49 8020 905-214, Fax +49 8020 905-100
    EMail: [email protected]

    Hello,
    if you are executing a DBMS_AQ.DEQUEUE and then perform a rollback in your code the counter RETRY_COUNT will not go up by 1.
    You are only reversing your own AQ action. This counter will be used only internally to log unsuccessful dequeue actions.
    Kind regards,
    WoG

  • Get records count of all tables

    Hi ,
    I am trying to get the record count of all tables using dynamic query. I don't know how to put the value in placeholder. I tried the below code.
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
         CURSOR table_list
         IS
         select OBJECT_NAME from user_objects
         where object_type in ('TABLE')
         and object_name not like '%AUDIT_DDL%'
         AND object_name not like 'MD_%'
         AND object_name not like 'EXT_%'
         AND object_name not like 'STG_%'
         AND object_name not like 'SYS_%'
         AND object_name not like 'TMP_%'
         AND object_name not like 'TEMP_%'
         order by 1;
         v_count     NUMBER :=0;
         query_str VARCHAR2(1000);
    BEGIN
         FOR table_name IN table_list
         LOOP
              query_str :='SELECT COUNT(1) FROM  ' || table_name.OBJECT_NAME;
    dbms_output.put_line(query_str);
              dbms_output.put_line('Table Name:' || table_name.OBJECT_NAME );
              v_count:= execute immediate query_str;
              dbms_output.put_line('Table Name:' || table_name.OBJECT_NAME || ', Count ' || v_count );
         END LOOP;
    END;
    I know I am doing wrong in the bold lines. But not sure how to fix it. Please help. Thanks in advance.

    Hi,
    Welcome to the forum!
    What you posted is basically right, assuming you really want to do dynamic SQL t all.
    The only problem with
    961618 wrote:
              query_str :='SELECT COUNT(1) FROM  ' || table_name.OBJECT_NAME; would be if the object name included special characters (such as single-quotes) or lower-case letters. To avoid any possible problems, I would put the object name inside double-quotes:
    ...     query_str := 'SELECT COUNT (*) FROM "' || table_name.OBJECT_NAME
                                               || '"';
              v_count:= execute immediate query_str;
    The correct syntax is
    execute immediate query_str INTO v_count;V_count will be the number of rows in a single table. Keep another variable (say total_v_count) that keeps the total count so far.
    Do you really need dynamic SQL?
    SELECT     SUM (num_rows)     AS total_rows
    FROM     user_tables
    WHERE     table_name     NOT_LIKE '%AUDIT_DDL%
    AND     ...
    ;gets the same information, accurate as of the last time statistics were gathered, and some of the numbers may be approximate. Depending on how you use the results, that may be good enough for you. If you actually have 10,000,123 rows, and the query says you have 10,000,000, does it really matter?

  • Record Count Limit for Lookup Flat tables

    Hello Experts,
    I wanted to know if there is any limit on the number of lookup values(records) that can be created in a Lookup Flat table. If yes, what is the limit and where can we find such details. Is there any SAP provided documentation for the same.
    Thanks in Advance.
    Best Regards,
    Uday

    Hi Udaya,
    There should be limited number of records in lookup table when we consider MDM Performance considerations.
    There is also desirable share of Main table records Vs lookup table provided by SAP.
    Please refer below documentation for more details: 8.1 Performance considerations Page 61/97 onwards.
    Kindly refer 8.3 Lookup tables and 8.5 Qualified tables
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70b0caa1-92e5-2c10-c687-a8d05e778e59?quicklink=index&overridelayout=true
    It clearly tells that in Section 8.3 Lookup tables,
    *Lookup tables and qualified lookup tables should have a very limited number of fields and number of records.
    *Lookup table that are not referred should be eliminated.
    *Lookup tables records between 10,000 and 100,000 records should be avoided.
    *Lookup tables records above 100,000 should be absolutely avoided.
    Regards,
    Mandeep Saini

  • Find SAP table records given a list of tables

    Dear all,
    I have been given a list of table names that I require to provide a report a total record counts for these table.
    given such codes I have can't proceed further as the field symbol that I use is invalid. Please advice how to complete this. Or perhaps any standard system reports to find the total record counts given a specified tables.
    here's the code:
    types : begin of w_dd02l,
               TABNAME type TABNAME,
               totalrec like sy-dbcnt,
            END OF w_dd02l.
    data : wa_dd02l type STANDARD TABLE OF w_dd02l with HEADER LINE.
    data : wr_dd02l type w_dd02l.
    data : totalrecord like sy-dbcnt.
    field-SYMBOLS : <f1> type ANY.
    p_tab is a selection field.
    select tabname from dd02l into CORRESPONDING FIELDS OF TABLE wa_dd02l where tabname in p_tab.
    loop at wa_dd02l into wr_dd02l.
       assign wr_dd02l-tabname to <f1>.
       select count(*) from <f1> into totalrecord.
       wr_dd02l-totalrec = totalrecord.
      write : wr_dd02l-tabname, wr_dd02l-totalrec.
    ENDLOOP.
    <f1> being a field symbol is not recognize as in ABAP dictionary. Here's where I can't proceed.. dear gurus please help.
    Thanks and Regards,
    Andrew

    Pl. check, it's working
    types : begin of w_dd02l,
              TABNAME type TABNAME,
              totalrec like sy-dbcnt,
            END OF w_dd02l.
    data : wa_dd02l type STANDARD TABLE OF w_dd02l with HEADER LINE.
    data : wr_dd02l type w_dd02l.
    data : totalrecord like sy-dbcnt.
    field-SYMBOLS : <f1> type ANY.
    PARAMETERS: p_tab like dd02l-tabname.
    * p_tab is a selection field.
    select tabname from dd02l
                   into CORRESPONDING FIELDS OF TABLE wa_dd02l
                  where tabname = p_tab.
    loop at wa_dd02l into wr_dd02l.
      assign wr_dd02l-tabname to <f1>.
      select count(*) from (<f1>) into totalrecord.      " use  like (<f1>)
      wr_dd02l-totalrec = totalrecord.
      write : wr_dd02l-tabname, wr_dd02l-totalrec, <f1>.
    endloop.

  • Data Load : Number of records count

    Hi Experts,
              I want to document number of records transferred to BW during an infopackage execution.
              I want to automate the process by running a report in background which will fetch a data from SAP tables about number of records been transfered by all my InfoPackage .
    I would like to know how should I proceed with.
             I want to know some System tables which contains same data as that of RSMO transaction displays to us.
    Kindly help with valuable replies.

    HI,
    inorder to get the record counts report you need to create a report based on below tables
    rsseldone, rsreqdone, rsldpiot, rsmonfact
    Check the below link which explain in detail with the report code as well.
    [Data load Quick Stats|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/90215bba-9a46-2a10-07a7-c14e97bdb764]
    This doc also explains how to trigger a mail with the details to all.
    Regards
    KP

  • Record Count Issue in Search page ?

    Hi Friends
    I am trying to display record count on Search page and I have the following code in
    The table has total of 62 Rows
    AM : for testing purpose, i am printing in log
    public void getISAGRecordCount()
    OAViewObject vo = (OAViewObject)getXXG2_ELIM_ISAGSView1(); //getXXG2ISAGSearchVO1();
    int fetchedRowCount = 0;
    vo.setMaxFetchSize(-1);
    vo.executeQuery();
    fetchedRowCount = vo.getRowCount();
    System.out.println("RowCount: "+ fetchedRowCount);
    IN PFR of CO: I am calling by this way
    am.invokeMethod("getISAGRecordCount");
    the Issue is
    for the first time, when i search  Based on search criteria, I know it should dispaly 10 records  but in the Log file i see the total Record Count of the Table     Ex; 62
    When i do the serach for the second time, based on search criteria, I know it should display 20 records, but the log file has 10 records ( previous search results)
    If I do the search for 3rd time, I see 2nd search results in log
    Any help in this issue, how to fix this?
    Thanks
    Ravi

    Hi,
    Please donot use getRowCount(), use getFetchedRowCount() and remove setMaxFetchSize(-1).
    Hope it will resolve your issue.
    Just for understanding of the concept:
    getFetchedRowCount() returns the number of rows cached in the view object -- including programmatically inserted rows.
    The getRowCount() implicitly execute a query against the database (if a query has not been executed yet)
    Regards,
    Reetesh Sharma

  • How to determine the cursor record count before the "open cursor"?

    Is it possible to determine the record count of an explicit cursor without running a count()? Say, my cursor definition is something like this,
    CURSOR cur_vehicle
    IS
    SELECT os.order_id, os.order_item, vs.part_id
    vs.part_num,
    vs.iso_num,
    vs.model_yr
    vs.dealer_cde,
    vs.cust_cde,
    px.plant_cd
    FROM parts_source vs,
    orders_source os,
    plant_tbl_crossref px
    wHERE os.order_id = vs.order_id
    AND vs.part_id = os.part_id
    AND vs.plant_cde = px.plant_cde
    ORDER BY os.order_id;
    I want to log the count of records returned by the above cursor prior to the first fetch, without running a count(1) for the query in cursor select.
    I know adding " Count(1) over(order by null) " in the cursor SELECT will bring it. But that does not help me log the record count to some log file or table before opening the cursor for processing.
    To conclude, my objective is to update the record count of cursor in some table before processing

    sarvan wrote:
    Is it possible to determine the record count of an explicit cursor without running a count()?
    ..snipped..No. The only way to do it correctly is inside that select.
    Each select is a consistent read. Which means that if this is done as 2 select statements, the 1st select can see a different version of the data than the 2nd select statement. does. So if you want a count and that to be consistent and on the same version of the data than the select, it has to be done as part of the select.
    Also consider what a cursor is. It is not a result set of sorts that is created in memory upfront - with a convenient interface that tells you the size/number of rows of that result set.
    A cursor is basically a program that reads database data as input and produce output. A fetch from a cursor is an instruction for this program to execute and output data.
    There's no data set that is created by the cursor from which the count can be determined. The cursor program does have state variables - like +%RowCount+ that specifies how many rows the cursor has thus far output. And you need to run that cursor to the end (no more output) in order to determine the total number of rows output by the cursor.

Maybe you are looking for

  • JDBC Receiver Adapter:Incorrect syntax near the keyword 'FROM'

    Hi All, I'm trying to get data from an SQL 2005 server using synchronous JDBC receiver adapter. I'm using PI 7.0. My outgoing message is as follows:   <?xml version="1.0" encoding="UTF-8" ?> - <ns0:MT_IZIN_YUKU_REQ xmlns:ns0="http://holding.com/brd/"

  • IMac 21.5" MC309LL/A -- Can I have an external monitor?

    Hello all -- I have a 2011 iMac Model MC309LL/A -- Is it possible to have a 2nd display on this iMac? I've done some research and it seems you can with the 2010 model -- so im a bit confused as why they would take this feature away in a newer year. A

  • Can't open Backup File in FCPX

    After a software update, when we open Pro my students events and projects are gone. I see the project and event files in the backup folder, and I tried deleting the current version of the project and replacing with the backup, but the backup will onl

  • Mobile Me & Best Practice

    I may be the only one here but i philosophically see all iOS firmware as work in progress but one none the less that leads from the front. In saying this i wish to make known and get feedback from others of my thinking on best practice for the Mobile

  • Massive iDVD project-Need help breaking it up

    I have been working on a comprehensive DVD of all of my family photos dating back to 1890. I have chapters split up by decades and then submenus within divided up by years. It is almost 2000 photos (no iMovies). Each year is its own slideshow with mu