Getting counts from detail tables

I have multiple record bock that displaye a list of cell ids and their attributes; each record also displays record counts of its 3 detail tables.
Originally, the POST-QUERY trigger select the counts (3 detail tables) as part of the data block for each record (or cell id). There are over 16K records, so each record query issues 3 selects. The whole query toke over a minute. I was asked to improve the retrieval time.
At first I thought perhaps I could put the 3 counts in 3 separate data blocks and issue one query each in a "select cell_id, count(*). . . group by cell_id" but scrolling would not synchronize with the other blocks. So I dropped that idea.
Next, I added a program unit from which the WHEN-NEW-FORM-INSTANCE trigger calls after execute_query. It issues "select cell_id, count(*). . . group by cell_id" (one for each detail table) and fills the count columns in the original data block. However I need to set the block property Query All Records to YES so that the cell ids and attributes are filled first. That means that before the form comes up it has to retrieve all records. That saves me about 10-15 seconds od retrieval time and I lose the ability to quickly bring up the form.
Then I looked at using dfferent Query Data Source Types. I don't think I could do one query with counts of detail tables. Besides, some items (attrinutes) of the cell are upate-able.
Any ideas and suggestions will be appreciated.

Yes. I suggested adding columns to the master tables and introduce stored triggers.
Since the change is not trivial, according to management, they put in on hold.I'm not sure if you misunderstood my suggestion or were responding to a different post. The query I wrote was for counting the detail records on the fly rather than populating new columns. If you include the counting in your main query then you will probably not have a much slower query than if you don't show any counts at all. Scrolling through the block will be no slower than if you had no counts, because no extra processing needs to be done. (You'll still have to fetch the detail blocks for each row, so moving to the last record will still be slow - that's a bad indicator of the performance of a query.)
For example, fetching the objects for each user takes 5 seconds. When I include the number of tables, indexes and constraints for each user within the query the time only goes up to just under 9.
SQL> set autot trace stat
SQL> set timing on
SQL> SELECT
  2    owner,
  3    object_name,
  4    object_type
  5  FROM all_objects ao;
39062 rows selected.
Elapsed: 00:00:05.13
Statistics
       4656  recursive calls
          0  db block gets
      85106  consistent gets
          0  physical reads
          0  redo size
    1469372  bytes sent via SQL*Net to client
      29021  bytes received via SQL*Net from client
       2606  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      39062  rows processed
SQL> SELECT
  2    owner,
  3    object_name,
  4    object_type,
  5    (SELECT Count(*) FROM all_tables WHERE owner = ao.owner) count_tables,
  6    (SELECT Count(*) FROM all_indexes WHERE owner = ao.owner) count_indexes,
  7    (SELECT Count(*) FROM all_constraints WHERE owner = ao.owner) count_constraints
  8  FROM all_objects ao;
39062 rows selected.
Elapsed: 00:00:08.86
Statistics
       4656  recursive calls
          0  db block gets
     270299  consistent gets
          0  physical reads
          0  redo size
    1684042  bytes sent via SQL*Net to client
      29021  bytes received via SQL*Net from client
       2606  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      39062  rows processed
SQL> If you populate the counts in post-query then the process is similar to the block below. I tried to get a timing and stats for this but it took over 15 minutes so I shut it down.
DECLARE
ct NUMBER;
ci NUMBER;
cc NUMBER;
BEGIN
  FOR ao IN (SELECT owner, object_name, object_type FROM all_objects)
  LOOP
    SELECT Count(*) INTO ct FROM all_tables WHERE owner = ao.owner;
    SELECT Count(*) INTO ci FROM all_indexes WHERE owner = ao.owner;
    SELECT Count(*) INTO cc FROM all_constraints WHERE owner = ao.owner;
  END LOOP;
END;Creating a view on the query and writing the "instead of" triggers is hopefully a trivial enough operation that management won't get in the way. Then you'll be able to update the block.

Similar Messages

  • Collumn Count from Database Table

    Hello,
    I wan't to get a Collumn Count from a Table in my Database, but I don't know how to do that.
    I use a ResultSet, and if i press ctrl + spacebar in NetBeans I get a list of all kind of things I can get out of the result set but I can't find CollumnCount anywhere.
    I thought I could use a try catch statement like this:
    try
    for(i=1; i<999; i++)
    myResultSet().getString(i);
    catch( Exception e )
    AantalKolommen = i--;
    But everytime I get an Exception over Invalid Crursor State and "i" keeps standing on 1.
    Does anybody know a way to find out how to get a collumns count????

    To retrieve the columns for a table use
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)
    To get the columns for your result set use
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSetMetaData.html#getColumnCount()
    To get the ResultSetMetaData use
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#getMetaData()

  • Getting Result from multiple table using code table.

    I am having hard time getting data from different table not directly connected.
    

    The data model is not proper. Why should you store the game details in separate tables?
    IMO its just matter of putting them in same table with additional field gamename to indicate the game. That would have been much easier to query and retrieve results
    Anyways in the current way what you can do is this
    SELECT p.ID,p.Name,c.CategoryName AS [WinnerIn]
    FROM GameParticipants p
    INNER JOIN (SELECT ParticipantID, Value AS ParticipantName,'CGW Table' AS TableName
    FROM CGWTable
    UNION ALL
    SELECT ParticipantID, Value AS ParticipantName,'FW Table' AS TableName
    FROM FWTable
    SELECT ParticipantID, Value AS ParticipantName,'WC Winner' AS TableName
    FROM WCWinner
    ... all other winner tables
    )v
    ON v.ParticipantID = p.ID
    AND v.ParticipantName = p.Name
    INNER JOIN Category c
    ON c.TableName = v.TableName
    If you want you can also add a filter like
    WHERE p.Name = @Name
    to filter for particular player like Henry in your example
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • POPUP FM to get values from a table control?

    I know about the FM POPUP_GET_VALUES to get one or more values from a popup dialog box.  I would like to find a similar FM that allows getting values from a table control or something that allows entry of multiple lines of values.  Is there such a thing, or do I need to write my own?

    it depends on what values you want to enter, better write your own to have a control on the function.

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • How to get data from a table in a condition between twomonth

    hai friends
    I have a query that is i want to get data from a table based on a condition between two months in a format of char column
    Ex
    I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
    then the second column is to_month in the same format 'mon/yyyy'
    now i wiil select from_month and to_month like
    from month jan/2009
    to month mar/2010
    how to use between of two months in the format of char.Please tell me how to get two different month between data.

    Hi,
    This may be of help.
    Remember Pointless has made a point ;) (worth millions)
    If possible , DO NOT store dates as strings or numbers.Let dates be dates.
    WITH dat AS
    (SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
    SELECT * FROM dat
    WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
    Bhushan

  • How to get data from COSP table, field HRKFT as the key to data from PM?

    Dear ladies and gentlemen!
    I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
    The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
    All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
    What should I do in this case?
    Thank you very much in advance!

    From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
    Of course, it's not a very good solution, but for now I know no other way to solve this problem.
    Maybe someone knows better ways? In this case I will be very grateful for any help!
    Moderator: You'd better post it on BI forums

  • How to get data from large table (more than 9 million rows) by EJB?

    I have a giant table, it has more than 9 million rows.
    I want to use ejb finders method to get data from this table but always get not enough memory error or time out error,
    Can anyone give me solutions?
    Thx

    Your problem may be that you are simply trying to load so many objects (found by your finder) that you are exceeding available memory. For example if each object is 100 bytes and you try to load 1,000,000 objects thats 100Mb of memory gone.
    You could try increasing the amount of memory available to OC4J with the appropriate argument on the command line (or in the 10gAS console). For example to make 1Gb available to OC4J you would add the argument:
    -Xmx1000m
    Of course you need have this available as hard memory on your server or you will incur serious swapping.
    Chris

  • Condition Record PB00 gets deleted from A018 table

    Hi Gurus-
    Could anyone of you explain how the PB00 condition is getting deleted from A018 table (Purch Org Level Condition)? It looks like some batch job is randomly setting the Valid to Date A018-DATBI to yesterday's date and today there is no valid time dependent condition.
    I don't know any process/program that accesses PB00 condition in table A018 other than MEK1 or MEK4.
    Does SD condition type change has any impact in Purchasing Price (PB00). Although all the Rate/Price is stored in the same table KONP but separated by application area and table (A017, A018, A071, A073).
    Can anybody shed some lights on this please?

    Thanks for your reply. We know the user name who is making the change in A018. It is a batch user ID that makes the change but we have about 100 differentg background batch job that is scheduled everyday and I went through every one of them but did not raise any flag.
    And the worst part is since it is done by the batch user id (batch job), there is no change record (if I try to do MEK3-Environment>display changes) not even an entry in CDHDR table or CDPOS table.
    Trying to see if you guys know of any SD or MM program that accesses that table and set the valid to field to yesterdays date and create a new condition record (KNUMH) with valid to date 31.12.9999 and rate (value) to 0.00?
    Please let me know if you have any suggestion.
    Thanks in advance.

  • Jdbc getting data from multiple tables

    hi guys
    how can i get data from multiple tables in MSAccess
    please help

    >
    here is code thata i want to do
    i have 3 tables in my MSAccess databace
    Stud_O which consist name,surname fields
    Stud_I consist address,tel
    Stud_E department,faculty fields
    Based on this I would guess that you are missing a key field. There is no way to connect the tables.
    I make the class to insert data to the tables. But
    cant do getting datas from this tables.
    can anybody help me in making query
    and method that displays reultset strings to the
    textBoxes
    A select ...
    select name,surname from Stud_O. Use the executeQuery() method.

  • Getting data from 7 tables

    I am converting a servlet based application to struts framework.I have a screen which gets data from 7 tables.I cannot use a stored procedure so has to manage using SQL queries.I thought i will query each table and set it to my struts form.The screen has lot of drop down boxes .
    I have heard of composite design pattern .Please let me know the best way to query the tables.Here are the queries.
    Select a.proj_id , a.proj_nm
    From stn_proj_et a, stn_proj b
    Where a.proj_id = b.proj_id
    And a.sftwr_id = 24
    And b.stn_id = 56602;
    Select round(utm_x,3) utm_x, round(utm_y,3) utm_y, stn_id
    From stn_loc_hist
    Where stn_id ='56602'
    And cur_use_cd = 1
    select data_tp_cd
    from data_coll_summ
    where stn_id ='56002'
    And rownum < 2;
    select lat_no,long_no,pnt_loc_dsc,srce_id,mthd_dtrmn_cd,ctrl_dtm_cd
    from stn_et
    where stn_id = '56002';
    select
    distinct sjr_utils.getcatalogvalue(mthd_dtrmn_cd)
    from stn_et;
    select
    distinct sjr_utils.getcatalogvalue(ctrl_dtm_cd)
    from stn_et;
    select distinct PROJ_NM from stn_proj_et where sftwr_id=24;
    Select a.stn_alias_nm stn_alias_nm, b.alias_orgn_nm alias_orgn_nm
    From stn_alias_nm a, alias_orgn_et b
    Where a.alias_orgn_id = b.alias_orgn_id
    And b.alias_orgn_tp = 0
    And stn_id = '56002';

    adithiananya wrote:
    I am converting a servlet based application to struts framework.How well do you know Struts?
    I have a screen which gets data from 7 tables.I cannot use a stored procedure so has to manage using SQL queries.I thought i will query each table and set it to my struts form.The screen has lot of drop down boxes .You don't need a stored procedure to query a database.
    I have heard of composite design pattern .This ain't it.
    Please let me know the best way to query the tables.Here are the queries.
    Select a.proj_id , a.proj_nm
    From stn_proj_et a, stn_proj b
    Where a.proj_id = b.proj_id
    And a.sftwr_id = 24
    And b.stn_id = 56602;What are those hard-wired magic numbers in the WHERE clause?
    >
    Select round(utm_x,3) utm_x, round(utm_y,3) utm_y, stn_id
    From stn_loc_hist
    Where stn_id ='56602'
    And cur_use_cd = 1What are those hard-wired magic numbers in the WHERE clause?
    >
    select data_tp_cd
    from data_coll_summ
    where stn_id ='56002'
    And rownum < 2;What are those hard-wired magic numbers in the WHERE clause?
    >
    select lat_no,long_no,pnt_loc_dsc,srce_id,mthd_dtrmn_cd,ctrl_dtm_cd
    from stn_et
    where stn_id = '56002';
    select
    distinct sjr_utils.getcatalogvalue(mthd_dtrmn_cd)
    from stn_et;
    select
    distinct sjr_utils.getcatalogvalue(ctrl_dtm_cd)
    from stn_et;
    select distinct PROJ_NM from stn_proj_et where sftwr_id=24;What are those hard-wired magic numbers in the WHERE clause?
    Select a.stn_alias_nm stn_alias_nm, b.alias_orgn_nm alias_orgn_nm
    From stn_alias_nm a, alias_orgn_et b
    Where a.alias_orgn_id = b.alias_orgn_id
    And b.alias_orgn_tp = 0
    And stn_id = '56002';What are those hard-wired magic numbers in the WHERE clause?
    Do you really want to execute different requests given input from the users? (e.g., enter a value in a text box and see the drop down list boxes change)
    %

  • JSON - get data from Oracle table

    Hi all,
    I hope it is correct thread...
    My need is to get data from oracle table using JSON and show output at html table. I'm very new to JSON (got some experience in PL/SQL and basic html knowledge). Could someone direct me to manual or give me simple example?

    JSON is a way to format data, not a way to fetch data. Call it an alternative to XML.
    Are you perhaps talking about doing an ajax request to fetch data?

  • Getting statistics from multiple tables using conditional expressions (e.g. combining min, count, sum, etc) in PHP/MySQL

    Hi,
    I'm trying to get statistics from a variety of related tables
    where the statistical counts are based on comparing the value on
    one table with an equivalent value on a second table (and I want to
    view the results grouped by time period, day, week, month, etc);
    e.g.
    Consider two tables - Customer & Customer_Action which
    are related as a one-to-many (one customer can take many actions):
    Customer: id, create_date, customer_name, etc.
    Customer_Action: id, customer_id, create_date, action, etc.
    If the customer took their first action at the same time as
    they registered on the system (i.e. if the customer record was
    created at the same time as the very first action record)
    YES_count is incremented by 1 else
    NO_count is incremented by 1
    So running the query against the database the report would
    look something like:
    Customers Yes No
    January 8 5 3
    February 14 9 5 .... Etc.
    I've tried this around a number of different ways but always
    seem to end up with double counting in one way or another: see this
    sample data
    Customer Create_Date Action_Date
    01 05/07/2008 12:36 05/07/2008 12:36
    01 05/07/2008 12:36 28/08/2008 22:22
    02 10/07/2008 12:04 10/07/2008 12:04
    03 10/07/2008 12:12 10/07/2008 12:12
    This should give me
    Count Yes No
    July 3 3 0
    ...... but I get always get a customer counts of 4 2 2!
    My current statement is .....
    SELECT count( m2u_Customer.id ) AS Customer,
    min( m2u_Customer_Action.action_date ) AS 'Action_Date',
    DATE_FORMAT( m2u_Customer.create_date, '%m-%M' ) AS Month,
    sum(case when m2u_Customer.create_date =
    m2u_Customer_Action.create_date then 1 else 0 end) as Yes,
    sum(case when m2u_Customer.create_date !=
    m2u_Customer_Action.create_date then 1 else 0 end) as No
    FROM m2u_Customer
    LEFT JOIN m2u_Customer_Action ON ( m2u_Customer.id =
    m2u_CustomerAction.customer_ id )
    WHERE m2u_Customer.create_date > '2008-07-02'
    AND m2u_Customer.create_date < '2008-08-01'
    GROUP BY DATE_FORMAT( m2u_Customer.create_date, '%m-%M' )
    Can this be done?
    Regards.
    Patrick

    In the default php.ini is set open_basedir which limits work with php only to few directories (and directories bellow them). There is set /srv/http, /home,/tmp and /usr/share/pear by default.
    To allow your vhost you should add /data/www or set empty value.

  • File to Jdbc: how to get record count from DB table

    Hello,
    i have a scenario file to JDBC....ihave to insert input file data to DB table.
    now my requirement is ..if i insert a file with 50 records to db table on first time, and then next time if i insert the file with 100 records to db table....the count should start from 51 in db table.
    if i insert another file 3rd time, with 25 records, the count shold start from 151...so how can i achieve this functionality....
    i think following options:
    1. in mapping write lookup to call JDBC sender channel and fetch count and map same to target filed of DB. if this is ok...please provide UDF code..2. db triggers (not suitable for my req.)
    So kindly let meknow possible solutions and required UDF codes..please
    Thanks in advance...SARAN

    >>>..if i insert a file with 50 records to db table on first time, and then next time if i insert the file with 100 records to db table....the count should start from 51 in db table.
    if i insert another file 3rd time, with 25 records, the count shold start from 151...so how can i achieve this functionality....
    i think following options:
    Suggestions:
    1)Create an id column in db table.  Talk to DB guy to create oracle sequencer for that column. So, every time you insert record that field will be updated with oracle sequencer. You dont need to handle this.
    Refer this link
    http://www.techonthenet.com/oracle/sequences.php
    2) If you want to handle via pi,  following suggestions..
    If you use PI 7.1 or above, use jdbc lookup in the mapping and do the query  something like this
    Refer this link
    /people/jin.shin/blog/2008/02/15/sap-pi-71-mapping-enhancements-series-graphical-support-for-jdbc-and-rfc-lookups
    Do select query as below
    select count(*) from tablename;
    the above query will return number of rows exist in the table. So use that value and map it in the target field.
    If you use pi 7.0 or below then use the previous reply and do the UDF implementation for jdbc lookup during mapping. Because jdbc lookup does not support in those versions.
    Hope that helps.
    Baskar

  • Getting data from REGUP table

    Hi All,
    I am working on a report where i need to get the data from few tables and get it displayed, in the requirement I need to get some data from REGUP based on the vendor and then I am trying to retrieve the information from PAYR table such as check #, check date. So far I have tried selecting the information from REGUP using the vendor number entered by the user and then I am doing a select on PAYR to get the other information for all the entries in my REGUP internal table. Using a simple select statement is taking lot of time and I am having performance issues, can you please suggest any better approach? I understand REGUP is a huge table.
    Thanks,
    Raj

    Hi Raja,
    RUGUH is Payment header table and REGUP is payment item table.
    If your basic requirement is to pick data from PAYR table only then why don't you write query as below,
    Select
    laufd
    laufi
    hktid
    hbkid
    from reguh
    into table it_data_reguh
    where ZBUKR = 'ZTC'
    AND    lifnr in s_lifnr.
    sort it_data_reguH.
    select chect
               bancd
    for all entries in it_data_reguH
    into table it_data_payr
    where ZBUKR = 'ZTC'
    AND hbkid = it_data_reguH-hbkid
    AND HKTID = it_data_reguH-hKTid
    AND laufd = it_data_reguH-laufd
    and  laufi =  it_data_reguH-laufi.
    After doing above you can pick entries from REGUP if required as REGUP contains item details against the paymnt header details IN REGUH, you will also find all key fields of REGUP table from REGUH table hence your performance will definitely get improve.
    Hope it will help you.
    Regards,
    Umang Mehta

Maybe you are looking for

  • Windows Server 2012 Essentials Connection Software not working

    This comes in response to a ticket I got great help from a user on but I'm still stuck on the connection software bit. Original Thread: http://social.technet.microsoft.com/Forums/windowsserver/en-US/0a7e6d91-98c7-42f2-9cdd-66117df91d76/win-2012-essen

  • I can't get Xcode 4 to display anything in the console...help!

    I'm running a simple "hello world" program just to test xcode 4, and when I build it, xcode says the build succeded but not a thing shows up in the debug console....it's throwing me for a loop because i've had no problems running xcode 4 on my work c

  • Purchase order - multiple address

    Hi We have a plant in Canada for which we are procuring materials from vendors. In the PO we send to the vendors, we have to mention the ship to address as the Freight forwarders address in the US border and the final destination in Canada. What is t

  • Word Count Funtion?

    Can you select part of a document for a word count and can you determine word count from an entire pages document?

  • Height of Controlbar

    Hello all, 1. I would like to change the Position of the Elements (Play Button, Scrubbar) in the Controlbar.     Q: How to do that? ... is there any tutorial or hints? An Example would be nice 2. Does anyone know where the height of the Controlbar is