Count number of rows for TWO QUERIES USING MINUS OPERATOR

I have the following piece of sql, i would like to know how could i programatically using plsql count the number of rows returned by the following statement. I know that %ROWCOUNT returns the rowcount for the last execute INSERT, UPDATE, DELETE and SELECT INTO statement. Any help is much appreciated thanks.
select *
from admt1m4.usr@tcprod u
where u.authoriztion = 'Omf99FullUsage'
and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug where ug.left in
(select obid from admt1m4.usrgrp@tcprod g 
where g.participant not in ('super user grp', 't1_WbsPSAnalystGrp')))
and u.activeuser = '+'
MINUS
select *
from admt1m4.usr@TCPROD u
where u.authoriztion = 'Omf99FullUsage'
and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug
where ug.usrgrpname in ('super user grp', 't1_WbsPSAnalystGrp'))
and u.activeuser = '+'

Hi,
Have you tried
SELECT COUNT (1) cnt
  FROM (SELECT *
          FROM admt1m4.usr@tcprod u
         WHERE u.authoriztion = 'Omf99FullUsage'
           AND u.obid IN (
                  SELECT RIGHT
                    FROM admt1m4.usrtogrp@tcprod ug
                   WHERE ug.LEFT IN (
                            SELECT obid
                              FROM admt1m4.usrgrp@tcprod g
                             WHERE g.participant NOT IN
                                      ('super user grp', 't1_WbsPSAnalystGrp')))
           AND u.activeuser = '+'
        MINUS
        SELECT *
          FROM admt1m4.usr@tcprod u
         WHERE u.authoriztion = 'Omf99FullUsage'
           AND u.obid IN (
                  SELECT RIGHT
                    FROM admt1m4.usrtogrp@tcprod ug
                   WHERE ug.usrgrpname IN
                                     ('super user grp', 't1_WbsPSAnalystGrp'))
           AND u.activeuser = '+')or your requirement is something else...
*009*

Similar Messages

  • Can I use same result set for two queries?

    Hi,
    Can I use the same result set for two queries?
    For example:
    ResultSet rs = null;
    rs = ps.executeQuery(query1);
    while (rs.next()) {
    rs = ps.executeQuery(query2);
    while (rs.next()) {
    Is it OK to use? or Is there any preformance issues?
    Appreciate your help.
    Thanks in advance.
    Prasad Vagolu

    Sure. You have a variable of ResultSet type. First you create a ResultSet and assign it to that variable. Then later you create another ResultSet and assign it to that same variable. Assigning an object reference to a variable takes essentially no time, and at any rate it isn't any faster to assign it to a different variable. Also, no matter whether you use one variable or two, you are still creating two ResultSets.
    However, you really should be closing your ResultSets after you finish using them. That's nothing to do with the assigning-to-a-variable question.

  • Gather_Plan_Statistics + DBMS_XPLAN A-rows for parallel queries

    Looks like gather_plan_statistics + dbms_xplan displays incorrect A-rows for parallel queries. Is there any way to get the correct A-rows for a parallel query?
    Version details:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi on HPUX
    Create test tables:
    -- Account table
    create table test_tacprof
    parallel (degree 2) as
    select object_id ac_nr,
           object_name ac_na
    from all_objects;      
    alter table test_tacprof add constraint test_tacprof_pk primary key (ac_nr);
    -- Account revenue table
    create table test_taccrev
    parallel (degree 2) as
    select apf.ac_nr         ac_nr,
           fiv.r             tm_prd,
           apf.ac_nr * fiv.r ac_rev
    from   (select rownum r from all_objects where rownum <= 5) fiv,
           test_tacprof apf;
    alter table test_taccrev add constraint test_taccrev_pk primary key (ac_nr, tm_prd);
    -- Table to hold query results
    create table test_4accrev as
    select apf.ac_nr, apf.ac_na, rev.tm_prd, rev.ac_rev
    from test_taccrev rev,
         test_tacprof apf
    where 1=2;
    Run query with parallel dml/query disabled:
    ALTER SESSION DISABLE PARALLEL QUERY;
    ALTER SESSION DISABLE PARALLEL DML;
    INSERT INTO test_4accrev
       SELECT /*+ gather_plan_statistics */
              apf.ac_nr,
              apf.ac_na,
              rev.tm_prd,
              rev.ac_rev
         FROM test_taccrev rev, test_tacprof apf
        WHERE apf.ac_nr = rev.ac_nr AND tm_prd = 4;
    SELECT *
      FROM TABLE (DBMS_XPLAN.display_cursor (NULL, NULL, 'ALLSTATS LAST'));
    | Id  | Operation          | Name         | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Use
    |*  1 |  HASH JOIN         |              |      1 |  30442 |  23412 |00:00:00.27 |     772 |  1810K|  1380K| 2949K (0)|
    |   2 |   TABLE ACCESS FULL| TEST_TACPROF |      1 |  26050 |  23412 |00:00:00.01 |     258 |       |       |    
    |*  3 |   TABLE ACCESS FULL| TEST_TACCREV |      1 |  30441 |  23412 |00:00:00.03 |     514 |       |       |    
    ROLLBACK ;
    A-rows are correctly reported with no parallel.
    Run query with parallel dml/query enabled:
    ALTER SESSION enable PARALLEL QUERY;
    alter session enable parallel dml;
    insert into test_4accrev
    select /*+ gather_plan_statistics */ apf.ac_nr, apf.ac_na, rev.tm_prd, rev.ac_rev
    from test_taccrev rev,
         test_tacprof apf
    where apf.ac_nr = rev.ac_nr
    and   tm_prd = 4;    
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));                
    | Id  | Operation                | Name         | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-M
    |   1 |  PX COORDINATOR          |              |      1 |        |  23412 |00:00:00.79 |       6 |       |       |          |
    |   2 |   PX SEND QC (RANDOM)    | :TQ10001     |      0 |  30442 |      0 |00:00:00.01 |       0 |       |       |          |
    |*  3 |    HASH JOIN             |              |      0 |  30442 |      0 |00:00:00.01 |       0 |  2825K|  1131K|          |
    |   4 |     PX BLOCK ITERATOR    |              |      0 |  30441 |     0 |00:00:00.01 |       0 |       |       |          |
    |*  5 |      TABLE ACCESS FULL   | TEST_TACCREV |      0 |  30441 |      0 |00:00:00.01 |       0 |       |       |       
    |   6 |     BUFFER SORT          |              |      0 |        |      0 |00:00:00.01 |       0 | 73728 | 73728 |          |
    |   7 |      PX RECEIVE          |              |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |   8 |       PX SEND BROADCAST  | :TQ10000     |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |   9 |        PX BLOCK ITERATOR |              |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |* 10 |         TABLE ACCESS FULL| TEST_TACPROF |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    rollback;
    A-rows are zero execpt for final step.

    I'm sorry for posting following long test case.
    But it's the most convenient way to explain something. :-)
    Here is my test case, which is quite similar to yours.
    Note on the difference between "parallel select" and "parallel dml(insert here)".
    (I know that Oracle implemented psc(parallel single cursor) model in 10g, but the details of the implementation is quite in mystery as Jonathan said... )
    SQL> select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod               
    PL/SQL Release 10.2.0.1.0 - Production                                         
    CORE     10.2.0.1.0     Production                                                     
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production                        
    NLSRTL Version 10.2.0.1.0 - Production                                         
    SQL>
    SQL> alter system flush shared_pool;
    System altered.
    SQL>
    SQL> alter table t parallel 4;
    Table altered.
    SQL>
    SQL> select /*+ gather_plan_statistics */ count(*) from t t1, t t2
      2  where t1.c1 = t2.c1 and rownum <= 1000
      3  order by t1.c2;
      COUNT(*)                                                                     
          1000                                                                     
    SQL>
    SQL> select sql_id from v$sqlarea
    where sql_text like 'select /*+ gather_plan_statistics */ count(*) from t t1, t t2%';
    SQL_ID                                                                         
    bx61bkyh9ffb6                                                                  
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor('&sql_id',null,'allstats last'));
    Enter value for sql_id: bx61bkyh9ffb6
    PLAN_TABLE_OUTPUT                                                              
    SQL_ID  bx61bkyh9ffb6, child number 0          <-- Cooridnator and slaves shared the cursor                          
    select /*+ gather_plan_statistics */ count(*) from t t1, t t2 where t1.c1 = t2.c
    1 and rownum <= 1000 order by t1.c2                                            
    Plan hash value: 3015647771                                                    
    PLAN_TABLE_OUTPUT                                                              
    | Id  | Operation                  | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |                               
    |   1 |  SORT AGGREGATE            |          |      1 |      1 |      1 |00:00:00.62 |       6 |       |       |          |                                   
    |*  2 |   COUNT STOPKEY            |          |      1 |        |   1000 |00:00:00.62 |       6 |       |       |          |                                   
    |   3 |    PX COORDINATOR          |          |      1 |        |   1000 |00:00:00.50 |       6 |       |       |          |                                   
    |   4 |     PX SEND QC (RANDOM)    | :TQ10002 |      0 |     16M|      0 |00:00:00.01 |       0 |       |       |          |                                   
    |*  5 |      COUNT STOPKEY         |          |      0 |        |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |*  6 |       HASH JOIN BUFFERED   |          |      0 |     16M|      0 |00:00:00.01 |       0 |  1285K|  1285K|  717K (0)|                                   
    |   7 |        PX RECEIVE          |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |   8 |         PX SEND HASH       | :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |   9 |          PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |* 10 |           TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  11 |        PX RECEIVE          |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  12 |         PX SEND HASH       | :TQ10001 |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  13 |          PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |* 14 |           TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    38 rows selected.
    SQL>
    SQL> select sql_id, child_number, executions, px_servers_executions
      2  from v$sql where sql_id = '&sql_id';
    SQL_ID                                  CHILD_NUMBER EXECUTIONS                
    PX_SERVERS_EXECUTIONS                                                          
    bx61bkyh9ffb6                                      0          1                
                        8                                                          
    SQL>
    SQL> insert /*+ gather_plan_statistics */ into t select * from t;
    10000 rows created.
    SQL>
    SQL> select sql_id from v$sqlarea
    where sql_text like 'insert /*+ gather_plan_statistics */ into t select * from t%';
    SQL_ID                                                                         
    9dkmu9bdhg5h0                                                                  
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor('&sql_id', null, 'allstats last'));
    Enter value for sql_id: 9dkmu9bdhg5h0
    PLAN_TABLE_OUTPUT                                                              
    SQL_ID  9dkmu9bdhg5h0, child number 0       <-- Coordinator Cursor                         
    insert /*+ gather_plan_statistics */ into t select * from t                    
    Plan hash value: 3050126167                                                    
    | Id  | Operation            | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers |                                                                    
    |   1 |  PX COORDINATOR      |          |      1 |        |  10000 |00:00:00.20 |       3 |                                                                    
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |   3 |    PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |*  4 |     TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    SQL_ID  9dkmu9bdhg5h0, child number 1        <-- Slave(s)
    insert /*+ gather_plan_statistics */ into t select * from t                    
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 3050126167                                                    
    | Id  | Operation            | Name     | Starts | E-Rows | A-Rows |   A-Time  | Buffers |                                                                    
    |   1 |  PX COORDINATOR      |          |      0 |        |      0 |00:00:00.01 |       0 |                                                                    
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |   3 |    PX BLOCK ITERATOR |          |      1 |  10000 |   2628 |00:00:00.20 |      16 |                                                                    
    |*  4 |     TABLE ACCESS FULL| T        |      4 |  10000 |   2628 |00:00:00.02 |      16 |                                                                    
    SQL>
    SQL> select sql_id, child_number, executions, px_servers_executions
      2  from v$sql where sql_id = '&sql_id';  <-- 2 child cursors here
    SQL_ID                                  CHILD_NUMBER EXECUTIONS                
    PX_SERVERS_EXECUTIONS                                                          
    9dkmu9bdhg5h0                                      0          1                
                        0                                                          
    9dkmu9bdhg5h0                                      1          0                
                        4                                                          
    SQL>
    SQL> set serveroutput on
    -- check mismatch
    SQL> exec print_table('select * from v$sql_shared_cursor where sql_id = ''&sql_id''');
    Enter value for sql_id: 9dkmu9bdhg5h0
    SQL_ID                        : 9dkmu9bdhg5h0                                  
    ADDRESS                       : 6AD85A70                                       
    CHILD_ADDRESS                 : 6BA596A8                                       
    CHILD_NUMBER                  : 0                                              
    UNBOUND_CURSOR                : N                                              
    SQL_TYPE_MISMATCH             : N                                              
    OPTIMIZER_MISMATCH            : N                                              
    OUTLINE_MISMATCH              : N                                              
    STATS_ROW_MISMATCH            : N                                              
    LITERAL_MISMATCH              : N                                              
    SEC_DEPTH_MISMATCH            : N                                              
    EXPLAIN_PLAN_CURSOR           : N                                              
    BUFFERED_DML_MISMATCH         : N                                              
    PDML_ENV_MISMATCH             : N                                              
    INST_DRTLD_MISMATCH           : N                                              
    SLAVE_QC_MISMATCH             : N                                              
    TYPECHECK_MISMATCH            : N                                              
    AUTH_CHECK_MISMATCH           : N                                              
    BIND_MISMATCH                 : N                                              
    DESCRIBE_MISMATCH             : N                                              
    LANGUAGE_MISMATCH             : N                                              
    TRANSLATION_MISMATCH          : N                                              
    ROW_LEVEL_SEC_MISMATCH        : N                                              
    INSUFF_PRIVS                  : N                                              
    INSUFF_PRIVS_REM              : N                                              
    REMOTE_TRANS_MISMATCH         : N                                              
    LOGMINER_SESSION_MISMATCH     : N                                              
    INCOMP_LTRL_MISMATCH          : N                                              
    OVERLAP_TIME_MISMATCH         : N                                              
    SQL_REDIRECT_MISMATCH         : N                                              
    MV_QUERY_GEN_MISMATCH         : N                                              
    USER_BIND_PEEK_MISMATCH       : N                                              
    TYPCHK_DEP_MISMATCH           : N                                              
    NO_TRIGGER_MISMATCH           : N                                              
    FLASHBACK_CURSOR              : N                                              
    ANYDATA_TRANSFORMATION        : N                                              
    INCOMPLETE_CURSOR             : N                                              
    TOP_LEVEL_RPI_CURSOR          : N                                              
    DIFFERENT_LONG_LENGTH         : N                                              
    LOGICAL_STANDBY_APPLY         : N                                              
    DIFF_CALL_DURN                : N                                              
    BIND_UACS_DIFF                : N                                              
    PLSQL_CMP_SWITCHS_DIFF        : N                                              
    CURSOR_PARTS_MISMATCH         : N                                              
    STB_OBJECT_MISMATCH           : N                                              
    ROW_SHIP_MISMATCH             : N                                              
    PQ_SLAVE_MISMATCH             : N                                              
    TOP_LEVEL_DDL_MISMATCH        : N                                              
    MULTI_PX_MISMATCH             : N                                              
    BIND_PEEKED_PQ_MISMATCH       : N                                              
    MV_REWRITE_MISMATCH           : N                                              
    ROLL_INVALID_MISMATCH         : N                                              
    OPTIMIZER_MODE_MISMATCH       : N                                              
    PX_MISMATCH                   : N                                              
    MV_STALEOBJ_MISMATCH          : N                                              
    FLASHBACK_TABLE_MISMATCH      : N                                              
    LITREP_COMP_MISMATCH          : N                                              
    SQL_ID                        : 9dkmu9bdhg5h0                                  
    ADDRESS                       : 6AD85A70                                       
    CHILD_ADDRESS                 : 6B10AA00                                       
    CHILD_NUMBER                  : 1                                              
    UNBOUND_CURSOR                : N                                              
    SQL_TYPE_MISMATCH             : N                                              
    OPTIMIZER_MISMATCH            : N                                              
    OUTLINE_MISMATCH              : N                                              
    STATS_ROW_MISMATCH            : N                                              
    LITERAL_MISMATCH              : N                                              
    SEC_DEPTH_MISMATCH            : N                                              
    EXPLAIN_PLAN_CURSOR           : N                                              
    BUFFERED_DML_MISMATCH         : N                                              
    PDML_ENV_MISMATCH             : N                                              
    INST_DRTLD_MISMATCH           : N                                              
    SLAVE_QC_MISMATCH             : N                                              
    TYPECHECK_MISMATCH            : N                                              
    AUTH_CHECK_MISMATCH           : N                                              
    BIND_MISMATCH                 : N                                              
    DESCRIBE_MISMATCH             : N                                              
    LANGUAGE_MISMATCH             : N                                              
    TRANSLATION_MISMATCH          : N                                              
    ROW_LEVEL_SEC_MISMATCH        : N                                              
    INSUFF_PRIVS                  : N                                              
    INSUFF_PRIVS_REM              : N                                              
    REMOTE_TRANS_MISMATCH         : N                                              
    LOGMINER_SESSION_MISMATCH     : N                                              
    INCOMP_LTRL_MISMATCH          : N                                              
    OVERLAP_TIME_MISMATCH         : N                                              
    SQL_REDIRECT_MISMATCH         : N                                              
    MV_QUERY_GEN_MISMATCH         : N                                              
    USER_BIND_PEEK_MISMATCH       : N                                              
    TYPCHK_DEP_MISMATCH           : N                                              
    NO_TRIGGER_MISMATCH           : N                                              
    FLASHBACK_CURSOR              : N                                              
    ANYDATA_TRANSFORMATION        : N                                              
    INCOMPLETE_CURSOR             : N                                              
    TOP_LEVEL_RPI_CURSOR          : N                                              
    DIFFERENT_LONG_LENGTH         : N                                              
    LOGICAL_STANDBY_APPLY         : N                                              
    DIFF_CALL_DURN                : Y      <-- Mismatch here. diff_call_durn
    BIND_UACS_DIFF                : N                                              
    PLSQL_CMP_SWITCHS_DIFF        : N                                              
    CURSOR_PARTS_MISMATCH         : N                                              
    STB_OBJECT_MISMATCH           : N                                              
    ROW_SHIP_MISMATCH             : N                                              
    PQ_SLAVE_MISMATCH             : N                                              
    TOP_LEVEL_DDL_MISMATCH        : N                                              
    MULTI_PX_MISMATCH             : N                                              
    BIND_PEEKED_PQ_MISMATCH       : N                                              
    MV_REWRITE_MISMATCH           : N                                              
    ROLL_INVALID_MISMATCH         : N                                              
    OPTIMIZER_MODE_MISMATCH       : N                                              
    PX_MISMATCH                   : N                                              
    MV_STALEOBJ_MISMATCH          : N                                              
    FLASHBACK_TABLE_MISMATCH      : N                                              
    LITREP_COMP_MISMATCH          : N                                              
    PL/SQL procedure successfully completed.

  • 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.

  • Different number of rows for different columns in JTable

    hi
    I need to create a JTable with different number of rows for different columns...
    Also the rowheight should be different in each column...
    say there is a JTable with 2 columns... Col1 having 5 rows and column 2 having 2 rows...
    The rowHeight in Col2 should be an integer multiple of Rowheight in Col1
    how do I do this ??
    can anybody send me some sample code ?????
    thanx in advance

    How about nesting JTables with 1 row and many columns in a JTable with 1 column and many rows.
    Or you could leave the extra columns null/blank.
    You could use a GridBagLayout and put a panel in each group of cells and not use JTable at all.
    It would help if you were more specific about how you wanted it to appear and behave.

  • Display the total number of rows for the report in OBIEE 11g

    Hi, In obiee 11g, the pagination will be 1-25. Is there any possiblity in obiee to show the total rows count next to pagination. Ex: if the result contains 120 rows. it should display after the pagination
    Records 1-25. Total of Records : 120
    Is there any way we can display the total number of rows for the report.
    Kindly help me.. Its very urgent requirement.
    MAny Thank in advacne

    Check this http://obiee100.blogspot.com/2011/07/display-total-number-of-records-in.html
    and
    http://docs.oracle.com/cd/E28280_01/bi.1111/e10544/appsql.htm#CHDCDIDA
    You have to go something like as suggested in previous link.
    Mark as correct/helpful

  • 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.

  • What is the maximum number of row for a table control in LabWindows/CVI ?

    I use LabWindows CVI 8.5.1 (MMI first developped in version 6.0).
    In one of our many MMI, a table control contains a list of aircraft parameters.
    We can add as many parameters (row) as we want but over 40 000 we observe a crash of the LabWindows CVI runtime.
    Our client want to inscrease the number of parameters (row) up to 200 000 !!!
    So my questions are:
    What is the real maximum number of row for the table control ?
    Is this maximum number of row different on LabWindows 2010 version ?
    Or is there an other solution ?
    Thanks

    Greetings,
    Can you clarify what you mean by "crash"? Is there an error message thrown? Is it possible that you've consumed all of the available memory?
    Please let me know.
    Thanks, James Duvall
    Product Support Engineer
    National Instruments

  • How to calculate number of rows for perticular characterstic in SAP BI Bex

    Hi experts,
    Please let me know how to calculate  ' number of rows  ' for perticular characterstic in Bex query. 
    Thanks & Regards,
    Babu..

    Hello,
    You can try this
    Create a CKF and assign the vale 1 to it. Open the query and select Character where you want to display ' number of rows ', go to properties windows, select 'display', in the results row drop down box, select  'always display'.
    Thanks.
    With regards,
    Anand Kumar

  • 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,

  • Error using minus operator

    table a
    =========
    id (number),name varchar2,dt date
    10,'aaa','01-01-2006'
    11,'bbb','01-01-2007'
    table b
    ======================
    id varchar2,name varchar2,dt varchar2
    '10','aaa','01-01-2006'
    is it possible to find out which row is not in table b but it is in table a
    i have tried out using minus operator but it return error (ora-01790-expression must have same datatype.

    ora-01790-expression must have same datatypeAnd what is it precisely is it about that error message which is confsuing you?
    SQL> select 1 from dual
      2  minus
      3  select dummy from dual
      4  /
    select 1 from dual
    ERROR at line 1:
    ORA-01790: expression must have same datatype as corresponding expression
    SQL> select to_char(1) from dual
      2  minus
      3  select dummy from dual
      4  /
    T
    1
    SQL> Cheers, APC

  • 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.

  • How To Restrict Number Of Rows For Multiple Group In Report Output

    Hi ,
    I have a requirement to restrict number of rows in report output.I have three different group , if i use same no of rows to restrict then output is as expected but if i want Deduction group should have 7 rows , earning should have 5 rows and Tax group have 3 rows in report output then XML tag is not working.
    Below is the XML tag i am using -
    First i have declare the variable to restrict the rows -
    <xsl:variable name="lpp" select="number(7)"/>
    <xsl:variable name="lpp1" select="number(5)"/>
    <xsl:variable name="lpp2" select="number(3)"/>
    For Each -
    <?for-each:PAYSLIP?>
    <xsl:variable xdofo:ctx="incontext" name="DedLines" select=".//AC_DEDUCTIONS"/>
    <xsl:variable xdofo:ctx="incontext" name="EarLines" select=".//AC_EARNINGS[ELEMENT_CLASSIFICATION!='Taxable Benefits']"/>
    <xsl:variable xdofo:ctx="incontext" name="EarTaxLines" select=".//AC_EARNINGS[ELEMENT_CLASSIFICATION='Taxable Benefits']>
    <?for-each:$DedLines?><?if:(position()-1) mod $lpp=0?> <xsl:variable name="start" xdofo:ctx="incontext" select="position()"/>
    <?if:(position()-1) mod $lpp1=0?><xsl:variable name="start1" xdofo:ctx="incontext" select="position()"/
    <?if:(position()-1) mod $lpp2=0?><xsl:variable name="start2" xdofo:ctx="incontext" select="position()"/>
    Report output is tabular form (one page has two column - Earning and Deduction ) . Tax group comes below earning group.
    Deduction Group -
    <?for-each-group:$DedLines;./REPORTING_NAME?><?if:position()>=$start and position()<$start+$lpp?>
    <?REPORTING_NAME?>
    <?end if?><?end for-each-group?>
    Earning Group -
    <?for-each-group:$EarLines;./REPORTING_NAME?><?if:position()>=$start1 and position()<$start1+$lpp1?>
    <?REPORTING_NAME?>
    <?end if?><?end for-each-group?>
    Tax Group -
    <?for-each-group:$EarTaxLines;./REPORTING_NAME?><?if:position()>=$start2 and position()<$start2+$lpp2?>
    <?REPORTING_NAME?>
    <?end if?><?end for-each-group?>
    Please let me know in case additional detail is require.
    Thanks in Advance.
    Thanks,
    Harsh
    Edited by: Harsh.rkg on Jan 14, 2013 9:43 PM

    variable lpp2 is declare to restrict EarTaxLines -
    <xsl:variable name="lpp2" select="number(2)"/>
    This will help to restrict the no of rows on one page , if we have more then two tax benefits line then layout will roll over to continuation page.
    As part of report output my expectation is if i restrict Earning , Deduction and Tax benefits to same no of line for example - variable lpp ,lpp1 and lpp2 have same value "number(2)" , we can see the layout is continue on next page (restrict every group can have max two lines) .This is the reason we have 4 header grid , deduction and Tax Benefit lines are rolled over to continuation page .But if we restrict different value for each variable then continuation page layout is missing .
    When we tried for <xsl:variable name="lpp2" select="number(3)"/> value continuation page layout is not getting generate for both employee number .

  • 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

  • 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.

Maybe you are looking for

  • How can I change the values of Withholding tax grid in MIRO trx

    Hi everyone, I am trying to change WT_WITHCD field in MIRO's Withholding tax grid by using  MRM_HEADER_CHECK. I developed the following code but the changes didn't appear in the screen:         LOOP AT i_rbkpv-h_rbws         INTO    r_h_rbws.        

  • Account has already been paid . . .

    Hey, HEY !      Several months ago I paid for Unlimited US and Canada , a 12-month subsctiption, got the original receipt too! Now I get a message warning 2nd time that my Credit is about to expire !!    Huh?!      What is going on?    The account in

  • Adding More InfoObjects into  a  Dimension

    Hi Team,     I  have  enhanced  2lis_11_vahdr  with  5  partner  functions (in 7.0). In order  to  load  the  data  into 2sd_c03 , Would  it  be OK to add  these 5 infoobjects  into the CUSTOMER dimension  which already  has 10  info  objects.? Is  t

  • Starting Issues (Blinking picture of Earth - on gray screen)

    My wife received a message stating that the startup disk was almost full (or full). I am not a techy in any way and was going to go through my HD to delete any unnecessary or unwanted program or file. Before I had the chance to do this, we lost power

  • Open excel worksheet in screen painter

    Hi, I'm just trying to open an excel worksheet in a screen. I think it should be very but I can't find anywhere how to do it. can you tell me where to look for it or give me some hints? Best regards!