SELECT COUNT(*) WHERE Receiver JDBC?

How can I do a SELECT COUNT(*) WHERE SQL statement with a Receiver JDBC?

Hi,
Refer this document - but if you have select query
"All return values are returned in an XML structure."
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
Hope this helps,
Regards,
Moorthy

Similar Messages

  • Select count(*) where exists (takes 5 hours).

    Hello Gurus,
    I have two databases on two servers, I am counting how many rows are similiar on two tables that are identical, and the rows should be identical as well. I am running a select count(*) where exists query and it takes 5 hours to complete.
    Each table only has two million rows.
    What can I do to speed it up?

    5 hours to process 2M rows does sound a bit long :(
    I didn't see this mentioned explicitly, but I thought the idea of comparing data on 2 servers implied a database link. Tuning distributed queries can be nasty.
    Start by getting an execution plan of the query to figure out what it is doing. Compare that to the plan generated by the already suggested MINUS operator. You'll need to do MINUS twice with each query in the other's position the second time. Alternately, check the indexing on the subqueries; EXISTS tends to work best with fast indexed lookups. FTS on an EXISTS subquery is not good :(
    Think about copying the data locally to one system or the other first, maybe in a materialized view or even global temporary table.
    Finally, think about tuning the transfer. There are articles on Metalink on tuning the transfer packet sizes (SDU/TDU) which might help IF YOU ARE ON UNIX; I haven't had any luck changing these values on Windows. You can also look into setting tcp.nodelay which can affect when packets get sent (another Metalink article should cover this).

  • Receiver JDBC Adapter for Count of records in Table

    Hi All,
    I am talking about Client Proxy to Receiver JDBC scenario.I've a requirement where i need to count the no of records created or updated in SQL server for particular transaction date.Question is- Is it possible to execute normal sql query to get the count or I need to write a stored procedure in SQL Server to be used by JDBC adapter.Please suggest with an example if possible.
    thanks for the help

    Hi.
    Pls check this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm
    action= EXECUTE
    Edited by: Luis Ortiz on Aug 26, 2010 2:27 PM

  • Select Query in the receiver JDBC

    Hello all,
    Is it Possible to use the select query in eceiver JDBC.
    Thanks,
    Srinivasa

    Hi Srinivas,
    You can either create the structure or can directly write the SQL_QUERY or| SQL_DML  statement where you will specifty the action SQL_QUERY | SQL_DML .
    So you can use either XML SQL Format or Native SQL Format. Please see this help srini:
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    Regards,
    ---Satish

  • Select Count(*) from Sample_table - how to get the count using JDBC?

    Hi All,
    It would be glad if anyone could help me with this. The problem is that I have to get the 'count' of records selected from a arbitrary table say, 'sample_table'. Is that possible to form the SQL in JDBC as
    Select Count(*) from Sample_table
    and get the value of the count? If yes, how?
    Thanks in advance
    Prabz

    stmt = con.createStatement();
    ResultSet recordcnt_rs = stmt.executeQuery("Select Count (*) as record_ctr From Sample_table");
    recordcnt_rs.next();     
    record_ctr = recordcnt_rs.getInt("record_ctr");
    hope this helps.

  • Receiver JDBC

    Hi
    the receiver JDBC structure
                                                                       occurence
    <statement1>   ----------------------------->                   1..unbound    or    1..1                               (1)
    <Table>            ----------------------------->                1..1 per statement always                             (2)
    <access>         ----------------------------->                  1..1 per statement always                             (3)
       <fld1></fld1>                                         
       <fld2></fld2>
    </access>
    <key> --------------------------------------->                   1..unbound    or  1..1                                       (4)                          
      <val1>
    </key>
    </statement1>
    <statement_response>  --------------->                        should be 1..unbound <b>if</b> statement request is 1..unbound (here statement1)
                                                                                    should be 1..1 <b>if</b> statement request is 1..1 (here statement1)                        (5)
    <row>                                       
    <row>
    </statement_response>
    -&gt; In which case we go for occurrence of statement (here statement1) = 1..unbound ??
    -&gt; if i need to select from one table do i need to use this as 1..unbound ?? Yes/No
    --&gt;each statement response (means all rows of that query) will come under row node with multiple occurrence Yes/No??
    --&gt;if i want to delete the rows from table where col= (value array) in this case i have to give key occurence as 1..unbound??Yes/NO
    --&gt;if i want to select all the data from one table..i no need any key..but as per sap help doc..if we dont specify the key the adapter will not accept and shows some error message...so i should some dummy key value..and need to compare with NEQ to NULL or space???
    --> If i want to select the data from JDBC using the receiver structure...can i declare all the field types as string in request and response structure..or it should match the data types of fields in data base..?? if so how it should be in select request and response structure??
    (1) (2) (3) (4) (5) are right or wrong..if wrong correct me..
    Thanks
    krish
    Edited by: murali krishna on Mar 24, 2010 5:30 PM

    Krish,
    Please see the below response
    Answer-1
    If you are selecting data from Different tables then you need to define Statement as 1.. Unbounded
    Answer- 2
    No. Since you are selecting data from one table - you can define it as 1..1
    Answer -3
    There will be only one Statement_Response per Statement. In other words if you have Multiple Statement in the Request , then you will have Multiple Statement(x)_Response
    So Under Statement_Response you will have Multiple Rows(for each record in the database) . YES - Row has to be 0.. Unbounded
    Answer- 4
    YES - You are correct
    Answer-5
    YES - you can define them all as a STRING. It shouldn't be a problem
    Hope it helps!
    Thanks!

  • Doubt in query statement in receiver jdbc

    HI
    Again a doubt in XML format for receiver jdbc.
    I want to execute a query
    select sum(col1) sum(col2) from tablename where startdate <= tdate.
    My payload message looks like this
    <AggregateFn action="SQL_QUERY">
      <access>SELECT sum(Weight) FROM KmFuelTrace WHERE resourceno = '$resno$' AND startdate = '$sdate1$'</access>
    - <key>
      <resno compareOperation="EQ">CHILLED_02</resno>
      <sdate1 compareOperation="LT">06/08/2007</sdate1>
       </key>
      </AggregateFn>
    I am getting a error "Data type mismatch in criteria expression" .
    I have defined the datatypes correctly with DateTrans function . I think its the problem with access statement.
    How to give the selection criteria for non-text fields. (can i use same quotes and dollar combination for date field too) . Or is there any other mistake in the xml structure

    Aarthi,
    Try the following
    <AggregateFn action="SQL_QUERY">
    <access>SELECT sum(Weight) FROM KmFuelTrace WHERE resourceno = '$resno$' AND startdate = $sdate1$</access>
    - <key>
    <resno compareOperation="EQ">CHILLED_02</resno>
    <sdate1 compareOperation="LT">06/08/2007</sdate1>
    </key>
    </AggregateFn>
    Also check what us the date format that database uses and give the similar format.
    Regards,
    Sudharshan N A
    Message was edited by:
            Sudharshan Aravamudan

  • When would you write a stored procedure in sender/receiver jdbc adapter

    Hi Everybody
    Can you tell any situation where you would need to write a stored procedure in the query sql statement of sender/ receiver jdbc adapter instead of writing SELECT statement there
    why do we need to write stored procedures
    thanks and regards,
    Anitha

    Hi Anitha,
    why do we need to write stored procedures
    Some times a single SQL statement will not suffice for ur transactions....
    Say u want to access from 2 tables and update based on some condition..
    or nested select statement...
    or u want to update a 2 nd table based on the values from 1st table... etc..
    In those places it's preferable for going for a Stored Procedure.
    The Stored Procedure can be used in both Sender and Receiver JDBC Adapter.
    Still nt clarified do post..
    Babu

  • Counting rows in JDBC

    I've recently come across the problem of needing to count the number of rows in a potentially large resultset.
    I did quite a bit of digging and found that the only suggested answers appear to be:
    1. Do a SELECT COUNT(*) before doing the query.
    2. Make the ResultSet scrollable, and use rset.last() and rset.getRow().
    I have problems with both approaches:
    1a. Two queries are issued rather than one - this could be quite expensive.
    1b. The queries I am executing are dynamic - thus some clever logic is required to parse the statement and work out what we should be counting.
    1c. The number of hits may change between the counting and the actual query.
    2a. Definitely most simple, but the Oracle JDBC driver iterates through all the rows to get to the last one, meaning that the whole ResultSet is loaded in to the client-side cache, and thus killing the middle-tier unnecessarily.
    2b. The results have to be scrollable - not a problem for me, but is too expensive for some.
    I had settled on number 2 for a while, but performance was just too nasty when the ResultSet had more than a few million rows in it, and thus I've spent the last few days looking around for better alternatives.
    select inner_2.*, rownum rowcount from (
    select inner_1.*, (rownum*-1) neg_row, rownum pos_row from (
    select COL1, COL2, COL3
    from TABLE1, TABLE2
    where TABLE1.COL1 = TABLE2.COL2
    order by event_type
    ) inner_1
    order by neg_row asc
    ) inner_2
    order by pos_row asc
    Let me explain. This query is determining the rowcount and returning the required columns all in one statement. All I need to do is look at the first row, and read the ROWCOUNT column (the last column) to know how many rows are in the resultset.
    The disadvantage of this method is that an extra two sorts are required, and that there are three extra columns on the result set, which the caller didn't ask for. Hiding the extra three column is easy if you want a really clean solution.
    These are definitely prices worth paying for me but I acknowledge that not everyone will find this price worth paying. However, having been immensely frustated with the lack of options for solving this problem, I thought I would share my solution with you all.
    And on a less-altruistic note, if anyone can tell me how to optimise it further, has a better solution, or knows why it doesn't actually work like it appears to, I'd be more than interested to hear your comments.
    Marcus

    If you need a consistent resultset, you could create a global temp table-- each session would then query the temp table and see a consistent resultset over time. This has the disadvantage that the database has to duplicate the resultset for each session, which probably only moves the caching problem.
    If your sessions don't go on forever and you have sufficient UNDO space, you can set the transaction isolation level to serializable. That will "freeze" the database to the point in time that the session begins. You need to have suffient UNDO, however, for the database to be able to reconstruct the database to that point in time and you need to be able to handle the situation where a user starts a session, walks away for the weekend, and comes back with an error indicating they need to reissue their query.
    If you want to really get sophisticated, you can use Oracle Workspace Manager to "branch" the data for each user. Workspace Manager would allow you to keep a consistent view of data forever without duplicating data for each session.
    The explain plan approach is useful as a rough estimate, not as an exact count. It's based on the statistics that the CBO is looking at, which ought to be close, but could easily be off by a factor of 2 or more depending on the complexity of the query. To get an actualt honest-to-goodness count, you need to incur the cost of a count(*). It seems to me, though, that if the data is particularly volitile, with the count constantly changing, it wouldn't be particularly useful to know the exact count at a point in time.
    Note that the SQL chunking method I outlined above is much more efficient retrieving the first few pages than the last few. If the resultset is large, my assumption is that people aren't actually going page-by-page through the entire thing-- that would seem incedibly inefficient. If they're likely looking at the first few pages and the last few pages, you'd want to have slightly different queries for the first and last few pages-- the inner query's ORDER BY clause would have to be reversed (i.e. ASC for the first pages, DESC for the last few pages). Then, the middle pages would be the most expensive.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • JDBC/select/async statement to JDBC/stored procedure/sync call

    Hi
    We have JDBC/select/async statement to JDBC/stored procedure/sync call i.e sender and receiver are JDBC.
    PI has to pick all the the records of single internal order number at a time from sender system and upload to receiver JDBc,
    gets the response and routes to sender/insert statement.
    This should run only once per day.
    We will have multiple Internal orders daily, each order consisting of 10 to 20 records but only one IO related records has
    to upload to Receiver/JDBC
    What are the options available ?
    We have thought of following options
    1. SQL query is already to pick, but we have to pick records at one time daily. example: morning,evening or midnight.
       At that time it can pick multiple times but it should not pick through out day
    2. Is there any option in BPM so that we can group IO's at a time and upload ? If so what are the steps need to use
       Any additonal receive step need to be used to pick the records from the table.
    Thanks

    hi
    as i can understando you, you will receive mani IO and you must execute one IO in the receiver SP? if so, you can solve this usssing a ccBPM where you will have to create a mapping(0.N) where the source and the target structure will be the same, the diferrence will be in the occurrance of the target structure which will have to be 0.N (Tab signature in Message Mapping). then back to the ccBPM define a block with the property ForEach. this will  loop any times accord with the number of IO that you receive from the sender. as a result you will execute one SP for each IO.
    so, you ccBPM will be
    RS>TS>BLOCK(Multiline container and single container of source structure)>TS->SS
    RS:Receive Step
    TS:Trans. Step
    SS:Send Step
    Also the container will be:
    source--> type Abs
    source_multiline --> type Abs
    target -->type Abs
    Thanks
    Rodrigo P.
    Edited by: Rodrigo Alejandro Pertierra on Jun 24, 2010 4:54 PM

  • Count Records from JDBC Sender

    Hi Experts,
    I have a requirement to process 80,000 records once a month from MS SQL Server to BW.
    After tuning of server and assigning the XBTM queue for the scenario didnt help much and brings down the J2EE engine everytime.
    Now i am thinking of processing 5000 records at a time in a BPM (in a while loop). But i somehow need to trap the overall number of records which is not always 80k.
    set rowcount 5000 SELECT * table_name where XIProcessed is NULL (SELECT COUNT(*) from table_name) 
    and then sending an UPDATE of XIProcessed flag to get the next 5000 rows in the JDBC sender.
    I somehow need to get the total number of records and the COUNT function will not help as i am getting 5000 rows at a time and not all.
    Thanks

    Hi Siva,
    why do you attempt counting in the BPM and adding all this overhead? Can't you just do that on the Database directly? In Oracle this is fairly easy as you can use the pseudo column rownum to limit your results. A search for rownum and SQL Server shows, that it is not as easy on SQL Server but there are still fairly simple ways to do this.
    Some sources:
    http://blogs.x2line.com/al/articles/173.aspx
    http://www.databasejournal.com/features/mssql/article.php/10894_2244821_2
    http://www.mcse.ms/archive94-2005-3-1502710.html
    From a performance standpoint i'm sure, it will work a lot better than any BPM into which you put 80000 records.
    Regards
    Christine

  • Performance issue when using select count on large tables

    Hello Experts,
    I have a requirement where i need to get count of data  from a database table.Later on i need to display the count in ALV format.
    As per my requirement, I have to use this select count inside a nested loops.
    Below is the count snippet:
    LOOP at systems assigning <fs_sc_systems>.
    LOOP at date assigning <fs_sc_date>.
    SELECT COUNT( DISTINCT crmd_orderadm_i~header )
       FROM crmd_orderadm_i
       INNER JOIN bbp_pdigp
           ON crmd_orderadm_iclient EQ bbp_pdigpclient               "MANDT is referred as client
         AND crmd_orderadm_iguid  EQ bbp_pdigpguid
         INTO w_sc_count
    WHERE crmd_orderadm_i~created_at BETWEEN <fs_sc_date>-start_timestamp
         AND <fs_sc_date>-end_timestamp
         AND bbp_pdigp~zz_scsys   EQ <fs_sc_systems>-sys_name.
    endloop.
    endloop.
    In the above code snippet,
    <fs_sc_systems>-sys_name is having the system name,
    <fs_sc_date>-start_timestamp is having the start date of month
    and <fs_sc_date>-end_timestamp is the end date of month.
    Also the data in tables crmd_orderadm_i and bbp_pdigp is very large and it increases every day.
    Now,the above select query is taking a lot of time to give the count due to which i am facing performance issues.
    Can any one pls help me out to optimize this code.
    Thanks,
    Suman

    Hi Choudhary Suman ,
    Try this:
    SELECT crmd_orderadm_i~header
      INTO it_header                 " interna table
      FROM crmd_orderadm_i
    INNER JOIN bbp_pdigp
        ON crmd_orderadm_iclient EQ bbp_pdigpclient
       AND crmd_orderadm_iguid   EQ bbp_pdigpguid
       FOR ALL ENTRIES IN date
    WHERE crmd_orderadm_i~created_at BETWEEN date-start_timestamp
                                          AND date-end_timestamp
       AND bbp_pdigp~zz_scsys EQ date-sys_name.
        SORT it_header BY header.
        DELETE ADJACENT DUPLICATES FROM it_header
        COMPARING header.
        describe table it_header lines v_lines.
    Hope this information is help to you.
    Regards,
    José

  • Table name in Receiver JDBC Adapter

    Hi All,
    I am using receiver JDBC adapter.
    But table name consist of " like BPC."#II" .
    After mapping table name becomes BPC.&quot;#II&quot; .
    I am getting error while pulling data from DB.
    Is the table name creating a problem.
    Please remedy of this if you have come across such scenario.
    Regards
    Piyush

    Hi Piyush,
    All that i could get from the SAP Help regarding JDBC Adapters are these links where i never found anything much regarding the table name.anyways just go through these links and see if you find anything useful.
    http://help.sap.com/bp_bpmv130/Documentation/Planning/XIUnicodeGuide030411.pdf
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/b0/676b3c255b1475e10000000a114084/content.htm">Configuring the Receiver JDBC Adapter</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/content.htm">Mapping Lookups</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/22/b4d13b633f7748b4d34f3191529946/content.htm">JDBC Adapter</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/content.htm">Configuring the Receiver JDBC Adapter - part 2</a>
    This is all i got from the help files, anyways you can also go through those links and see if you find anything else useful.
    - Escape Symbol for Apostrophe
    The apostrophe character (‘) is a reserved character in SQL syntax and is therefore replaced by an escape character if it occurs within value strings. This replacement character can be database-specific. Typical replacement characters are \’ or ’’(default value). If a character occurs that is invalid for the database being used, the adapter triggers an error message (an SQL exception) concerning the SQL syntax that is generated by the database.
    - Column Name Delimiter
    Depending on the database being used, column names can be enclosed by a special delimiter character, for example, if the names can contain special characters (such as ”). This character can be specified at this point. The default setting is no delimiter character. If a character occurs that i
    Also check if there are notes in the service market place related to the same.
    Regards,
    abhy
    Message was edited by: Abhy Thomas

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • Select count(*) statement in ABAP

    Hi,
    Im writing following statement in my Function module,
    select count(*) into l_count
    from user_master
    where username = l_username and
          process_type = processtype and
          password = oldpassword.
    And there is one entry in table user_master.
    But still, I'm getting l_count as zero..
    Can somebody help me with this.
    Regards,
    Amey

    select count(*) into l_count
    from user_master
    where username = l_username and
    process_type = processtype and
    password = oldpassword.
    Use group by option...
    Like this....
    select count(*) into l_count
    from user_master
    where username = l_username and
    process_type = processtype and
    password = oldpassword group by username.

Maybe you are looking for

  • How can I create a link to download a file in Captivate?

    So, in my Captivate file, I want people to be able to download an XML file to their machine.  If I create a hyperlink to "open a file", then when a user clicks on it, captivate attempts to open the xml file in a browser window instead of downloading

  • Printing a Customer Receivables Aging Report Doesn't Include PO #

    The standard Detailed Receivables Aging report uses variable 152 that is supposed to show the Cust/Vendor Ref No.  It doesn't show anything however.  I tried changing it to a database field and relating it to the document #, but that didn't pull in a

  • Technologies collaboration

    Hello everybody, and sorry for my bad english. I am searching for a document (picture or/and text) explaining how and when exactly technologies are used in a typical web application: I have a good idea about this, but some things are not really clear

  • LR and Printer Profiles

    Okay... I shoot in RAW. I make adjustments in LR before I make the move to my final edits in PS. When I assign a profile to the image such as the profiles found at www.drycreekphoto.com (in my case for Costco-CA-San Diego-Morena Blvd...) I get a seri

  • 2lis_11_vahdr extraction?? records mismatch

    hi experts, i am extracting data from r/3. in RSA3- 9400 RECORDS in PSA - 9400 RECORDS in INFOCUBE- 3200 RECORDS its full load and its not a delta. What could be the reason???? plz suggest me regards vadlamudi