JDBC adapter - update statement

I have come to the conclusion that there is no direct connection between the select and update statement of a sender JDBC adapter, in terms of commit scope.
According to SAP documentation:
"The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below)."
But my point is: if select statement retrieves e.g. 5 rows based on a where condition, then the update statement could find 6 rows to update, if a row was inserted a split second after the select, but before the update. Result : a row is lost...
I don't think the select statement puts a lock on the table(s) it accesses, and releases this lock after update has been committed. This would ensure integrity between select and update statement.
Can anybody confirm or deny this ?

Hi,
Have you seen the<b> Isolation level for Transaction handling</b> in the sender JDBC adapter?
Make the Isolation level as Serializable and repeatable Read and the db gets locked  anbd until Update happens, no Insertion can occur in the Split Second!
http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
Regards,
Bhavesh

Similar Messages

  • Sender JDBC adapter -- Update SQL statement NOT work for the last record

    I'm trying to use SAP XI to send records from Oracle database to As/400 using JDBC adapter.  I've defined the communication channel for sender
    (1)  The "Query SQL statement"  = select  a_bgn_dt,  a_end_dt from  PX_PXXD WHERE NOT CU_ACTION_CD='P' 
    (2)   The "Update SQL statement"  = update PX_PXXD set CU_ACTION_CD='P'  WHERE NOT CU_ACTION_CD='P' 
    Supposed that 3 records were retrieved from (1) and successfully updated to AS/400 but only the first 2 records in Oracle database are updated according to (2)
    Any advise.
    Pansy

    Hi Pansy,
    You select and update query is looking like wrong
    kindly check below query,If you are using oracle
    (1) The "Query SQL statement" = select a_bgn_dt, a_end_dt from PX_PXXD WHERE CU_ACTION_CD !='P'
    (2) The "Update SQL statement" = update PX_PXXD set CU_ACTION_CD='P' WHERE  CU_ACTION_CD !='P'
    Thank you
    Sateesh

  • Sender JDBC adapter : Update SQL Statement : stored procedure

    Hi,
    Can we use a stored procedure in the sender jdbc adapter in 'Update SQL Statement'.
    The problem i am facing is like, we are selecting data from two tables in 'SQL statement for query' and then in 'Update SQL Statement' , we need to delete that data from these two tables.
    Please let me know if it is possible.
    Thanks,
    Rohit

    you can use a Stored procedure in the
    Query SQL Statement
    You have the following options:
    ·        Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
    ·        Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
    The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs.
    so have your whole select and update as part of this single Stored procedure

  • JDBC Sender Adapter, Update statement

    Hi ALL,
               I have a JDBC to proxy scenario. We have stored procedure in the database that executess and sends the data to SAP.
    Also the same store procedure updates the field Status_ID to distinguish between read and unread records. Status_ID acts as a Flag.
    Now because the Stored procedure itself does what 'Update SQL Statement' in sender JDBC adapter does, what shall I put in 'Update SQL Statement' as it is not needed, but it's a mandatory field??
    XIer
    Message was edited by:
            XIer

    Do you need that update in the sender jdbc adaptor to do anything....?
    Dint think so..
    Change your update statement to update Status_ID if its not updated..and if the sql procedure has run already then its not going to be updated ..as it already is.......
    Regards
    Ravi Raman

  • JDBC Adapter - Update SQL Statement - Timestamp

    Hi All,
    I'm using a JDBC Sender channel to bring information from a database, when I bring the data I want to UPDATE a field inserting the date and time (timestamp) when you got the info.
    Sender Communication Channel: JDBC
    Query SQL Statement:  SELECT * FROM PI_Factory
    Update SQL Statement: ????????
    Could you tell me how to do this?

    Hi
    please try the below query in Update sql statement
    update table_name set fieldname = systimestamp where .....
    or
    update table_name set fieldname = current_timestamp where .....
    Regards
    Ramg.

  • JDBC adapter update statment

    Hello All,
    In my sender jdbc adpter configuration i read data from table that contains filed 'status' witch indicate does record has been send to sap. But limitation of this solution is that i read up to ne row and example query looks like this
    select up to 1 rows * from table where status = 0 order by id.
    and update query
    update table set status = 1 where id = ( select id 1 rows * from table where status = 0 order by id )
    Can you write your strategy of reading multiple records.
    I know that stored procedure can be solution of this problem, but i'm wondering how do you handle with that.
    BR
    Maciej

    you can indeed read and update multiple records;
    Adapter Work Method
    ·        You must add an indicator that specifies the processing status of each data record in the adapter (data record processed/data record not processed) to the database table.
    ·        The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
    ·        Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
    Example
    SQL statement for query: SELECT * FROM table WHERE processed = 0;
    SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
    processed is the indicator in the database.
    the above is from SAP help.
    follow the query as mentioned and do not forget to set the repeatable_read or serializable in the adapter
    http://help.sap.com/saphelp_nw04/helpdata/EN/7e/5df96381ec72468a00815dd80f8b63/frameset.htm

  • Sender JDBC Adapter - Stored procedure

    Hello all, I just read a lot of topics in this forum about this subject.
    I found two indications in contracdictions in the documentation :<a href="http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/frameset.htm">Configuring the Sender JDBC Adapter</a>
    1. Concerning Query SQL Statement
    You have the following options:
    &#9679;     Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
    &#9679;     Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
    2. Concerning Update SQL Statement :
    This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement.
    It is ambigous, isn't it ?
    My question is simple :
    Does somebody already use Sender JDBC Adapter with Stored procedure as Select statement including many steps :
    - update actions on database
    - select query to return data to XI adapter
    (Update statement stay empty or with value <TEST>.
    To provide more information, I have a reference table to read. But this reference table must be updated by a stored procedure before being able to be read accordingly.
    So As I can't do both process with Sender Adapter (call a procedure and execute a select statement) => I want to include both actions (updates and select) in an alone stored procedure.
    Could I get wanted data as a resultset ?

    Hi,
    >><i>Update statement stay empty or with value <TEST>.</i>
    It should be <TEST> if you do not want an Update to happen.
    Regarding Sender JDBC adapter with stored procedures, which DB are you trying to access. Sender JDBC adapter does not support Oracle Stored Procedures as they return Cursors and Sender JDBC adapter can deal with only Resultset.
    As for executing both Update and Select in the SP, though I havent tried, this should surely be possible.
    Regards,
    Bhavesh

  • Xi JDBC Adapter - Query SQL Statement & Update SQL Statement

    Hi!
    I configure the JDBC adapter sender (XI) to take data from Oracle database.
    I set the Query and Update SQL Statement in the Processing parameters of the communication channel in this way:
    Query SQL Statement :
    SELECT * FROM XI_TABLE WHERE STATUS = 'WAIT' ORDER BY ROW_NUM
    Update SQL Statement :
    UPDATE XI_TABLE SET STATUS = 'DONE', DATE = SYSDATE WHERE STATUS = 'WAIT'
    My question is :
    If a new record with the field STATUS = 'WAIT' is added to the table (xi_table) during the time between the execution of the query statement and the start of the update statement, what will happen to that record during the update?
    There is a way to avoid the update of that record? or to pass to the update statement only the record selected in the query statement?
    Please, may you give me some example?
    Thanks,
    Francesco

    hi,
    did you check "Isolation Level for Transaction"
    for the sender jdbc adapter?
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Regards,
    michal

  • Update- statement in JDBC sender Adapter

    Hi ,
    I have a requirement where I am trying to fetch data from ODS based on some flag and immediately I want to update the flag status . So I used selected and update in JDBC sender adapter .
    But I have one question , in the small timeframe where  XI has done a select and just before  XI could  issue the update statement  if a new record is added to ODS . Then  that new record will also get updated though it wasnot selected in select statement .
    Can someone let me know how to overcome this problem ; as I want to make sure I update only those recrods which are selected in select statement ??
    Thanks & Regards,
    Suvarna

    Hi,
    Check out the following thread. It gives the exact answer to this question.
    JDBC Sender Update Query
    One of the replies in the above thread:
    I put in an OSS note asking this exact question with your specific example, and got a reply. I was referred to OSS note 0000831162, where it is explained very unambiguously that the SELECT and UPDATE queries are run in the same transaction.
    Regards,
    P.Venkat
    Message was edited by:
            Venkataramanan

  • UPDATE statement in Receiver JDBC adapter

    Hi all,
    I would like to use UPDATE statement in my receiver JDBC adapter and would like to know how this UPDATE statement works in following case.
    1) If i have 10 records to be updated in database, whether Commit happens at the end of all 10 records updation OR it will be for every record update?
    Regards

    Hi,
    Then let me construct my query this way...
    i have 10 records that needs to be updated to database, say For Ex: 7 records are updated successfully and 8th record has issue in updating the table.
    In this case i would like to ROLLBACK entire 10 records with out committing any thing.
    So if i use your 2nd option, it should perform as i expected right?
    Regards

  • Update statement problem for jdbc adapter

    Hi all
    In the jdbc sender adapter, I configured as follows:
    Query statement
    select * from pickdiff where tid is null
    Update statement
    delete from pickdiff where tid is null
    I got following error message:
    Database-level error reported by JDBC driver while executing statement 'delete from pickdiff where tid is null'. The JDBC driver returned the following error message: 'java.sql.SQLException: [SQLServer 2000 Driver for JDBC][SQLServer]Die Unterabfrage gab mehr als einen Wert zurück. Das ist ungültig, wenn die Unterabfrage auf =, !=, <, <= , >, >= folgt oder als Ausdruck verwendet wird.'. For details, contact your database server vendor.
    If I change the Update statement to
    update pickdiff set tid = 'sapxi' where tid is null
    Then everything is ok.
    Doese any one have some idea about this problem?
    Regards
    Hui

    Hi,
    The below statements are from SAP help...
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/frameset.htm
    The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
    &#9679;      Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
    SQL statement for query: SELECT * FROM table WHERE processed = 0;
    SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
    processed is the indicator in the database.
    please see if setting the isolation level would help....Also are you getting this error always or is it intermitent ?
    Thanks,
    Renjith

  • Update sql statement in sender/receiver jdbc adapter

    Hi
    What is the update sql statement we give in the sender/ receiver adapter when
    1) SELECT statement was written in query sql statement
    2) EXECUTE statement was written for a stored procedure in query sql statement
    thanks
    Anitha

    > 1) SELECT statement was written in query sql statement
    your table should have some value "already_processed" which prevents a second processing of that table.
    the update statement sets that value.
    > 2) EXECUTE statement was written for a stored procedure in query sql statement
    the same as above.
    when your stored procedure already does the update, then write a second stored procedure which does nothing.

  • JDBC adapter - no UPDATE to database

    Hi,
    I have the scenario ABAP Proxy to XI to JDBC to read some data from a database and return some info back to BW. Is it mandatory to UPDATE the selected records in some way or can the UPDATE part of the adapter be disabled by putting something in the UPDATE parameter on the comm channel ?
    Cheers
    Colin.

    Hi Colin,
    if you are talking about a sender JDBC adapter: you can put <TEST> in the update statement.
    See this snippet from the help:
    <i>Update SQL Statement
    You have the following options:
    Enter a valid SQL statement that is to be applied to the database once the data (determined from the Query SQL Statement) has been successfully sent to the Integration Server/PCK.
    It must be an INSERT, UPDATE, or DELETE statement.
    In place of the SQL statement, you can also enter <TEST>. Once the data determined from Query SQL Statement has been successfully sent, the data in the database remains unaltered.
    This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement.</i>
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    If you want to synchronously call a receiver JDBC adapter, i think you can use action=SELECT without an update.
    Regards
    Christine

  • Execution time difference between SELECT & UPDATE statement in JDBC Sender.

    Hi Experts,
    In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
    Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
    So result of this is updation take place for those entries which are not even picked up by the select statement.
    Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
    Thanks & Regards
    Jagesh

    Hi
    Use serializable option in additional parameters, now all new entries would also be updated.

  • Sender JDBC adapter SELECT / UPDATE issue - updates more rows than selected

    Hi,
    We have configured a Sender JDBC Adapter to poll records from an Oracle table based on a flag field and then update the flag for the selected records. When tested in DEV and QA environments (where test data comes in intermittently and not in huge volumes), itu2019s working fine.
    Both SELECT and UPDATE queries written in the Sender JDBC adapter are getting properly executed and are changing the status of the flag for the selected records from Y to N once read from the database.
    select * from <table> where flag = 'N'.
    update <table> set flag = 'Y' where flag = 'N'.
    But in the PROD environment (with records getting updated in the database every second), after XI executes the SELECT query and just before the UPDATE query is executed, new records come into the Oracle table with status flag 'N". So when the UPDATE query runs just after the SELECT query, then these unselected records also get updated to 'Y'. Thus these records never get into the resultset and hence XI and thus remain unprocessed.
    So when XI does a SELECT and UPDATE on the Oracle DB table and concurrently there is an INSERT happening into the table from the other end, the JDBC sender adapter is picking up a certain number of records but updating the status of more records than it picked up.
    So how does XI deal with such a common scenario without dropping records?
    Thanks,
    Vishak

    The condition being checked is the same for both SELECT and UPDATE statements.
    Initially I tried setting transaction isolation levels on the database to repeatable_read and serializable but it was throwing me a java.sql.SQLException error saying that these transaction levels were not valid.
    I asked for these transaction level permissions for the XI user from my DBA but the DB I am accessing provides only a view into other databases and so it's not possible.

Maybe you are looking for