Multiple Stored Procs in Receiver JDBC with transaction handling

Hi All,
We have a requirement to call  two Stored procedured in Receiver JDBC -- such that if any one of those procedure fails it should rollback the transaction/ or in other words commit only when both are successful.
Is this handled in Receiver JDBC adapter?
Thanks,
Himadri

Hello KK,
Combining is not an option available for us.
Our requirement is there are two SPs. --  SP1 and SP2. SP1 is mapped from the header segment and called only once. SP2 is from Item segment and called multiple times based on number of items. If anyone of those calls fails the transaction should be rolled back.
Is it possible in the standard JDBC call in PI?
Thanks and Regards,
Himadri Chakraborty

Similar Messages

  • JDBC receiver adapter with multiple stored procs error

    Hi all,
      I am doing a scenario IDOC-XI-JDBC. The destination system in MS SQL server 2000. I am passing variant config information to update the destination tables by triggering the same stored procedure multiple times with different parameters.
      Everything is correct, but JDBC adapter is giving me the following error
    Unable to execute statement for table or stored procedure. 'mk_EditAllowedLowerSpineImprintingOptions_proc' (Structure 'CallProc') due to java.lang.IllegalArgumentException
    My payload looks like this. This is just a partial payload, the blocks of CallProc continue till the CallsRemaining number reaches zero(0).
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_UPDATEPERSONAVARIANTS xmlns:ns0="urn:sd:sales:sapvarianttablestopersona">
    - <CallProc>
    - <Update_Persona_Variants action="EXECUTE">
      <table>mk_EditAllowedLowerSpineImprintingOptions_proc</table>
      <AlbumType type="CHAR">7SPEC</AlbumType>
      <UpperSpineImprintingOption type="CHAR">UST</UpperSpineImprintingOption>
      <LowerSpineImprintingOption type="CHAR">NOL</LowerSpineImprintingOption>
      <EffectiveDate type="DATE">20040503</EffectiveDate>
      <CallsRemaining type="INTEGER">27</CallsRemaining>
      </Update_Persona_Variants>
      </CallProc>
    - <CallProc>
    - <Update_Persona_Variants action="EXECUTE">
      <table>mk_EditAllowedLowerSpineImprintingOptions_proc</table>
      <AlbumType type="CHAR">7SENT</AlbumType>
      <UpperSpineImprintingOption type="CHAR">UST</UpperSpineImprintingOption>
      <LowerSpineImprintingOption type="CHAR">LSP</LowerSpineImprintingOption>
      <EffectiveDate type="DATE">20040503</EffectiveDate>
      <CallsRemaining type="INTEGER">26</CallsRemaining>
      </Update_Persona_Variants>
      </CallProc>
    - <CallProc>
    - <Update_Persona_Variants action="EXECUTE">
      <table>mk_EditAllowedLowerSpineImprintingOptions_proc</table>
      <AlbumType type="CHAR">7SPEC</AlbumType>
      <UpperSpineImprintingOption type="CHAR">UST</UpperSpineImprintingOption>
      <LowerSpineImprintingOption type="CHAR">LSP</LowerSpineImprintingOption>
      <EffectiveDate type="DATE">20040503</EffectiveDate>
      <CallsRemaining type="INTEGER">25</CallsRemaining>
      </Update_Persona_Variants>
      </CallProc>
    ......CallProc blocks continue till CallRemaining reaches zero.
    I also tried making CallProc element appear just once in XML and repeating <Update_Persona_Variants> blocks like below
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_UPDATEPERSONAVARIANTS xmlns:ns0="urn:sd:sales:sapvarianttablestopersona">
    - <CallProc>
    - <Update_Persona_Variants action="EXECUTE">
    </Update_Persona_Variants>
    <Update_Persona_Variants action="EXECUTE">
    </Update_Persona_Variants>
    </CallProc>
    </ns0:MT_UPDATEPERSONAVARIANTS >
    but still i get the same error.
    Can anyone guide me what is wrong.

    Well,
      The problem was with the way date was passed to the stored procedure, i just needed to format the date to yyyy-mm-dd and the error was solved. The error given by the JDBC adapter was not correct. I tried using logSQLStatement additional parameter, but for stored procedures it does not give out the actual SQL statement being fired. I was able to find the error in log files found on WAS server in transaction AL11.
       So i suggest to everyone having issues with JDBC adapter, please do not trust the error given in runtime workbench, always crosscheck in the logs in AL11 at the following location in your XI box
    DIR_INSTANCE\J2EE\CLUSTER\SERVER0\log. Here find date and time when you triggered your scenario and search for your table name or stored proc name, the java dump will give you a good information.
      I am giving points to everyone anyways.
    Thanks
    Pulin

  • How to put Stored Procedure in Receiver JDBC channel

    Hi all,Good Evening,Iam using a JDBC to JDBC scenario in which I have to move the data from database into XI and we all know that the Interfaces which require stored procedures on Oracle database server for publishing the data needs to be called in combination of BPM & Receiver JDBC adapter.
            In this method, a dummy interface will be created for triggering the process. This interface could be designed using any adapter which works on polling mechanism (sender JDBC/File). Dummy interface will invoke a small BPM designed for each business object. BPM will make a synchronous call to Oracle database by calling underlying stored procedure. Stored procedure will return the result set by using a cursor. BPM will send this result set to target application.
            Now my question is how to put a stored procedure in a receiver JDBC channel which need to collect the data from database when BPM makes a synchronous call.
           Because it is required in my scenario,can any one tell me how and where to put stored Procedure in JDBC receiver channel.
    Thanks in advance,
    Regards,
    Prajwal

    Your action should be EXECUTE for stored procedures in Message mapping.
    <StatementName5>
    <storedProcedureName action=u201D EXECUTEu201D>
        <table>realStoredProcedureeName</table>
    <param1 [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
    </storedProcedureName > 
    </StatementName5>
    action=EXECUTE
    Statements with this action result in a stored procedure being executed. The name of the element is interpreted as the name of the stored procedure in the database. If you use the optional <table> element, the value specified here is used as the stored procedure name. This enables you, for example, to define stored procedure names containing non-XML-compatible characters or characters that prevent them from being used in interface definitions in the Integration Builder/PCK.  If specified, <table> must be the first element in the block within <dbTableName>.
    The elements within the stored procedure are interpreted as parameters. They can optionally have the attribute isInput=u201C1u201C (input parameter) or isOutput=u201C1u201C (output parameter) or both (INOUT parameter). If both attributes are missing, the element is interpreted as an input parameter. The parameter names must be identical to those of the stored procedure definition.
    The attribute type=<SQL-Datatype> , which describes the valid SQL data type, is mandatory for all parameter types (IN, OUT, INOUT).
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    /people/sap.user72/blog/2005/10/15/jdbc-adapter-execution-mode-chained-or-unchained
    /people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi

  • Stored Proc output being truncated with latest ojdbc14 and classes12.jar

    Hello,
    I downloaded the latest ojdbc14.jar from Oracle website and used it with my Java program. I noticed a peculiar behavior. If my stored proc is returning a VARCHAR with large number of characters, the output is being truncated. This worked fine with the older ojdbc14.jar (and the older classes12.jar). It does not work properly with the new ojdbc14 and classes12.jar. Is there something that I am missing here?
    My Oracle Server version is - Oracle Database 10g Enterprise Edition Release 10.2.0.1.0.
    Below is the sample stored proc and the Java file to execute the same.
    Am I missing something here?
    CREATE OR REPLACE PROCEDURE TestOracleDriver (returnVal OUT VARCHAR2) IS
    BEGIN
    returnVal := '';
    FOR tmpVar in 1..2000
    Loop
              returnVal := returnVal || to_char(tmpVar) || ',';          
    END LOOP;
    END;
    import java.sql.*;
    import java.util.*;
    import java.util.Hashtable;
    import oracle.jdbc.driver.OracleTypes;
    public class OracleDriverTest
         public static void main(String argv[]) throws Exception
              Connection c = null;
              try
                   Driver dr = new oracle.jdbc.OracleDriver();
                   Properties props = new Properties();
                   props.put("user", "scott");
                   props.put("password", "tiger");
                   c = dr.connect("jdbc:oracle:thin:@SERVER_NAME:PORT:SID", props);
                   System.out.println("GOT A PLAIN CON" );
                   System.out.println("The driver is " + c.getMetaData().getDriverVersion() );
                   System.out.println("The DBMS is " + c.getMetaData().getDatabaseProductVersion() );
                   execute(c);
              catch (Exception e)
              e.printStackTrace();
              finally { try {c.close();} catch (Exception ign){} }
         private static String execute(Connection connection )
                   String procName = "TestOracleDriver";
                   CallableStatement cstmt=null;
                   ResultSet rs = null;
                   String returnedData = null;
                   try
                        cstmt = connection.prepareCall("{call " + procName+" (?)}");
                        cstmt.registerOutParameter(1,OracleTypes.VARCHAR);
                        cstmt.execute();
                        returnedData = cstmt.getString(1);
                        System.out.println("ProcTest ::execute --> Returned data is \n"+ returnedData);
                        return returnedData;
              catch (Exception e) {
                   System.out.println("ProcTest ::execute -->Error while executing "+procName);
                   e.printStackTrace();
                   return null;
              finally
                   try
                        connection.close();
                   catch (Exception e1)
                        System.out.println("ProcTest ::execute -->Error while closing connection ");
                             e1.printStackTrace();
                   }//end of catch
         }//end of finally
    }//End of execute method
    Regards,
    Hari
    Message was edited by:
    user553601
    Message was edited by:
    user553601

    Hari,
    If you think it is a bug, you can report it to Oracle Support via the MetaLink Web site.
    Good Luck,
    Avi.

  • Multiple table insert using receiver jdbc adapter

    Hi,
    I am trying to insert data in to two tables in a single structure using receiver jdbc adapter. I am not using any stored procedure to insert data instead directly inserting the data using PI. Please see the structure I am using.
    SOURCE side:
    DT_ABC_SENDER
    --IT_HEADER_TEXT
      -- EBELN
      -- LINENO
      --TDTEXT
    --IT_ITEM_TEXT
      -- EBELN
      -- LINENO
      --TDLINE
    TARGET side:
    DT_ABC_RECEIVER
    --InsertStatement
         --HEADER_TEXT
                -- action                         (insert)
                -- Table                          (Table 1)
                --access
                     -- IDS_ENQ_NO
                     -- IDS_DESC
                     -- IDS_TEXT
       --ITEM_TEXT
                -- action                         (insert)
                -- Table                          (Table 2)
                --access
                     -- IIS_ENQ_NO
                     -- IIS_DESC
                     -- IIS_TEXT
    Using the above structure I am able to successfully insert the data in Table 1 but data is not getting inserted in Table 2.
    In sxmb_moni it is saying message successfully delivered but I but there is data insertion took place in Table 2.
    Please help me urgently.
    Thanks in advance.
    Neeeraj

    Hi Neeraj,
    Add --InsertStatement statement for the second table structure in the same level of first InsertStatement.
    Target structure like this:
    DT_ABC_RECEIVER
    --InsertStatement
         --HEADER_TEXT
                -- action                         (insert)
                -- Table                          (Table 1)
                --access
                     -- IDS_ENQ_NO
                     -- IDS_DESC
                     -- IDS_TEXT
    --InsertStatement
       --ITEM_TEXT
                -- action                         (insert)
                -- Table                          (Table 2)
                --access
                     -- IIS_ENQ_NO
                     -- IIS_DESC
                     -- IIS_TEXT

  • Report on results of multiple stored procs

    Post Author: RobotSlave
    CA Forum: Data Connectivity and SQL
    I'm creating a report where I have data coming from three different slightly related stored procs,  when I try to get sub totals from the result sets my data is all wacky. How to I get the totals right, here is a typical set of the recordsets:
    set 1:
    AMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 1 203.4100 Before Used Greater OtherAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 1 146.1800 Before New Greater PreferredAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 1 691.7800 Before Used Greater PreferredAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 21 9718.3800 Since New Greater OtherAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 1 196.5000 Since New Less OtherAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 4 820.9000 Since Used Greater OtherAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 22 7410.0500 Since New Greater PreferredAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 6 2683.0500 Since New Less PreferredAMERICAN SECURITY PLUS 2 221 AUBURN/HERITAGE FORD Active 3 1533.6900 Since Used Greater Preferred
    set 2:
    AMERICAN SECURITY PLUS AUBURN/HERITAGE FORD 2 221 114 51 1998-08-03 13:13:00.000 Active New GreaterAMERICAN SECURITY PLUS AUBURN/HERITAGE FORD 2 221 114 5 1998-08-03 13:13:00.000 Active New LessAMERICAN SECURITY PLUS AUBURN/HERITAGE FORD 2 221 114 17 1998-08-03 13:13:00.000 Active Used Greater
    set 3:
    AMERICAN SECURITY PLUS 2 AUBURN/HERITAGE FORD 221 .0000 .0000 New GreaterAMERICAN SECURITY PLUS 2 AUBURN/HERITAGE FORD 221 .0000 .0000 New LessAMERICAN SECURITY PLUS 2 AUBURN/HERITAGE FORD 221 .0000 .0000 Used Greater

    Post Author: RobotSlave
    CA Forum: Data Connectivity and SQL
    I think I will just consolidate this data into one set in a stored proc.

  • JDBC Adapter - transaction handling

    Hi,
    I have a question. I use graphical Message Mapping and standard documents formats for Receiver JDBC Adapter.
    Now I need to push a delete call and insert calls in one message looks like that one f.e.:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_CostcentreUpdate xmlns:ns0="http://rtl.de/xi/TransCostcenter">
    - <StmName>
    - <dbTableName action="DELETE">
      <table>KOSTENSTELLEN</table>
      </dbTableName>
    - <dbTableName action="INSERT">
      <table>KOSTENSTELLEN</table>
    - <access>
      <KOSTL>0000001000</KOSTL>
      <GUELTVON>2005-09-01</GUELTVON>
      <GUELTBIS>9999-12-31</GUELTBIS>
      <ABTEI>Test1</ABTEI>
      <VERAK>Name1</VERAK>
      <KHINR>K1000_1010</KHINR>
      <KTEXT>Test1</KTEXT>
      </access>
    - <access>
      <KOSTL>0000001001</KOSTL>
      <GUELTVON>2005-03-01</GUELTVON>
      <GUELTBIS>9999-12-31</GUELTBIS>
      <ABTEI>Test1</ABTEI>
      <VERAK>Name2</VERAK>
      <KHINR>K1000_1010</KHINR>
      <KTEXT>Test2</KTEXT>
      </access>
    - <access>
      <KOSTL>0000001006</KOSTL>
      <GUELTVON>2006-04-01</GUELTVON>
      <GUELTBIS>9999-12-31</GUELTBIS>
      <ABTEI>Test1</ABTEI>
      <VERAK>Name3</VERAK>
      <KHINR>K1000_1010</KHINR>
      <KTEXT>Test3</KTEXT>
      </access>
      </dbTableName>
    </StmName>
    </ns0:MT_CostcentreUpdate>
    Because I need to do both (delete & insert) in one transaction mode. But i will not work at the moment
    I always get error:
    com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'KOSTENSTELLEN' (structure 'StmName'): java.sql.SQLException: FATAL ERROR document format: invalid level 5' found (structure 'StmName')
    Thanks for any help
    Matt

    Hi Matthias,
    you need to have two statements (StmName), one for delete, one for insert.
    Regards,
    Udo

  • Multiple stored procs execution parallelly using single DBMS_SCHEDULER

    Hi All,
    I have to run 10 tasks - a few simultaneously, and a few periodically using DBMS_SCHEDULER.
    But instead of creating 10 different Schedulers, is there a way in Oracle to create a single scheduler and invoke the tasks base on respective times?
    I have been going thru SCHEDULERS documentation but i am unable to make much progress.
    Thanks,
    Chaitanya

    Hi,
    You can run the multiple process under the same scheduler to set the appropriate priority.
    DBMS_SCHEDULER.create_job (
    job_name => 'test_priority_job',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN DBMS_LOCK.sleep(10); END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'freq=minutely;',
    end_date => SYSTIMESTAMP + 1/48,
    enabled => FALSE,
    comments => 'Job used to test priorities.');
    DBMS_SCHEDULER.set_attribute (
    name => 'test_priority_job',
    attribute => 'job_priority',
    value => 1);
    DBMS_SCHEDULER.set_attribute (
    name => 'test_priority_job1',
    attribute => 'job_priority',
    value => 1);
    Like the above code.
    ~Kushal

  • How to handle BLOB field in receiver JDBC adapter into ABAP table

    Dear Experts,
    I am working in a synchronous scenario with Sender ABAP Proxy to Oracle Database as receiver via SAP PO 7.4.I will be calling a stored procedure view with fields ID, NAME,Age,*** and BLOB (Image binary).
    1. The response from Oracle Database field BLOB is to be stored in ABAP table.Would I have to write any JAVA program to read the BLOB or the receiver JDBC adapter will handle it and store in a table by using ABAP proxy once it reaches ECC.
    2. If yes, would the JAVA program have to deal with other 4 fields.
    3. Can I use a UDF mapping to this BLOB field.
    Regards
    Rebecca...

    Dear Praveen,
    Thanks for your response...
    Please correct me if I am wrong.
    1. For 1-1 response mapping for BLOB field, I will use just use the below UDF code.
    public static byte[] hexStringToByteArray(String s) { 
                int len = s.length(); 
                byte[] data = new byte[len / 2]; 
                for (int i = 0; i < len; i += 2) { 
                            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) 
                                                                                         + Character.digit(s.charAt(i+1), 16)); 
                return data; 
    2. ===Using the byte data, create binary attachment in mapping for abap proxy response===
    Could you please share how to create the binary attachment.. I am not clear
    Regards...

  • ORA-03113 error when running the Java stored proc demos

    Hi there,
    Has anyone else run into this issue. When attempting to transfer an object type from Java to Oracle - through a Java stored proc - the session crashes with:
    ORA-03113: end-of-file on communication channelLooking in the trace file generated the error message looks something like:
    ksedmp: internal or fatal error
    ORA-07445: exception encountered: core dump [0x8fe04468] [SIGTRAP] [unknown code] [0x8FE59034] [] []
    Current SQL statement for this session:
    select pointruntime.jdistance(point(1, 2), point(2, 3)) from dual
    ----- Call Stack Trace -----
    calling              call     entry                argument values in hex     
    location             type     point                (? means dubious value)    
    ksedmp+764           call     ksedst               0 ? 2C4F4A ? 2C ? 98968000 ?
                                                       DB02C ? 27A50000 ?
    ssexhd+956           call     ksedmp               3 ? 0 ? 8FE5E790 ? 5905870 ?
                                                       8FE0434C ? 40895E4 ?
    0x9012c860           call     ssexhd               5 ? BFFEEF70 ? BFFEEFB0 ? 0 ?
                                                       0 ? 0 ?As you can see from the trace snippet above, I was attempting to run one of the Oracle Java stored procedure demos. Has anyone successfully run those demos? Specifically the ones where complex types (table objects or the Point object) are passed back to Oracle from the JVM.
    I would appreciate some help with this. The code works fine in a Windows or Solaris environment but barfs on Apple. Truly annoying....
    Anyone?
    Thanks in advance,
    Alex

    Yes,
    Apologies for not stating that information, Steve. Was a bit naughty of me! I guess the reason I didn't was because I just wanted to hear if anyone else running Oracle on Mac received such errors when executing the Java stored proc demos (specifically, the execution of PointRuntime.jDistance). Nevertheless, here's the relevant info from the trace file:
    Dump file /Users/oracle/admin/sandbox/udump/sandbox_ora_1861.trc
    Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
    ORACLE_HOME = /Users/oracle/product/10.1.0/db
    System name:     Darwin
    Node name:     maczilla.local
    Release:     8.3.0
    Version:     Darwin Kernel Version 8.3.0: Mon Oct  3 20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC
    Machine:     Power Macintosh
    Instance name: sandbox
    Redo thread mounted by this instance: 1
    Oracle process number: 10
    Unix process pid: 1861, image: [email protected] for the Java version, according to the readme file in the javavm directory, I am running 1.4.1:
    1.5  Java Compatibility
    This release has been thoroughly tested with Sun's Java Compatibility
    Kit for the JDK 1.4.1. Oracle is committed to OracleJVM keeping pace
    with Java and other Internet standards.

  • Osb 11g transaction handling

    Hi,
    I have a problem with transaction handling in OSB 11g. When I add a report action, error messages disappear.
    The process is the following:
    jms-queue -> proxy-service ->business-service ->EBS webservice.
    In the proxy-service I add an error-handler at node-level. In this error-handler I log the error-message in the server log. In the regular process there is a request and response-pipeline.
    When I add a message on the queue and when the response from EBS is negative, the message is placed on a errorqueue. That's ok.
    When I add a report-action to the error-handler and then I put another message on the queue, the message is disappeared. It is not on the error-queue and not on the normal queue. When I look in the database there is an extra row added.
    I use the default datasource(wlsbjmsrpDataSource).
    I found for example this blog: http://biemond.blogspot.nl/2010/11/global-transactions-and-quality-of.html ; but I can't find an example with writing to a database and a rollback to an errorqueue. The report-action needs it's own transaction.
    In the weblogic console -> datasources -> transaction I unchecked "Keep Connection After Local Transaction" but that didn't work.
    What kind of options is possible?
    Herman

    I cant believe i was answered by the famous Anuj!.
    You were correct. The weird thing, is that in publish actions the QoS is not propagated onto the target of that Publish per se.
    We say this, becouse the Local PS has the Transaction Required = True, ergo the QoS is Exactly Once all along its message flow. It also propagates in the service callout´s and Route Node´s. Thats why we, trying to avoid redundance, didnt specified it in the publish action.
    Thank you very much.
    Regards.
    Mario.

  • Transaction Handling - JDBC Receiver Adapter - Multiple SP Calls

    Hello,
    I have the following scenario:
    I send an XML-SQL structure with multiple statment elements (each of them calling a different stored procedure). A stored procedure raises an error back to the JDBC Receiver Adapter in case of error.
    Is it possible to have transaction handling in the JDBC Receiver to ensure:
    - Commit only after ALL stored procedures where succesful (no error risen during calls)
    - Rollback of ALL already called stored procedures in case an error has been risen
    How can I implement these requirements in the JDBC Receiver Adapter?

    One more comment, I have found the following info for JDBC Drivers:
    <i> "JDBC driver's default is to autocommit, meaning that the result of every SQL statement is permanent as soon as it is executed. This is why the course hasn't had to be concerned with transactions so far, and is perfectly acceptable in many cases."</i>
    So I think that each SP-Call is automatically commited in case autocommit on JDBC Driver Level is set to "true". Does anyone know where I can change these settings? Directly on JDBC Receiver Adapter or do I have to go to Visual Admin for those changes?

  • Problem Obtaining multiple results from MySql Stored Proc via JDBC

    I've spent alot of time on this and I'd be really grateful for anyones help please!
    I have written a java class to execute a MySQL stored procedure that does an UPDATE and then a SELECT. I want to handle the resultset from the SELECT AND get a count of the number of rows updated by the UPDATE. Even though several rows get updated by the stored proc, getUpdateCount() returns zero.
    It's like following the UPDATE with a SELECT causes the updatecount info to be lost. I tried it in reverse: SELECT first and UPDATE last and it works properly. I can get the resultset and the updatecount.
    My Stored Procedure:
    delimiter $$ CREATE PROCEDURE multiRS( IN drugId int, IN drugPrice decimal(8,2) ) BEGIN UPDATE drugs SET DRUG_PRICE = drugPrice WHERE DRUG_ID > drugId; SELECT DRUG_ID, DRUG_NAME, DRUG_PRICE FROM Drugs where DRUG_ID > 7 ORDER BY DRUG_ID ASC; END $$
    In my program (below) callablestatement.execute() returns TRUE even though the first thing I do in my stored proc is an UPDATE not a SELECT. Is this at odds with the JDBC 2 API? Shouldn't it return false since the first "result" returned is NOT a resultset but an updatecount? Does JDBC return any resultsets first by default, even if INSERTS, UPDATES happened in the stored proc before the SELECTs??
    Excerpt of my Java Class:
    // Create CallableStatement CallableStatement cs = con.prepareCall("CALL multiRS(?,?)"); // Register input parameters ........ // Execute the Stored Proc boolean getResultSetNow = cs.execute(); int updateCount = -1; System.out.println("getResultSetNow: " +getResultSetNow); while (true) { if (getResultSetNow) { ResultSet rs = cs.getResultSet(); while (rs.next()) { // fully process result set before calling getMoreResults() again! System.out.println(rs.getInt("DRUG_ID") +", "+rs.getString("DRUG_NAME") +", "+rs.getBigDecimal("DRUG_PRICE")); } rs.close(); } else { updateCount = cs.getUpdateCount(); if (updateCount != -1) { // it's a valid update count System.out.println("Reporting an update count of " +updateCount); } } if ((!getResultSetNow) && (updateCount == -1)) break; // done with loop, finished all the returns getResultSetNow = cs.getMoreResults(); }
    The output of running the program at command line:
    getResultSetNow: true 28, Apple, 127.00 35, Orange, 127.00 36, Bananna, 127.00 37, Berry, 127.00 Reporting an update count of 0
    During my testing I have noticed:
    1. According to the Java documentation execute() returns true if the first result is a ResultSet object; false if the first result is an update count or there is no result. In my java class callablestatement.execute() will return TRUE if in the stored proc the UPDATE is done first and then the SELECT last or vica versa.
    2. My java class (above) is coded to loop through all results returned from the stored proc in succession. Running this class shows that any resultsets are returned first and then update counts last regardless of the order in which they appear in the stored proc. Maybe there is nothing unusual here, it may be that Java is designed to return any Resultsets first by default even if they didn't happen first in the stored procedure?
    3. In my stored procedure, if the UPDATE happens last then callablestatement.getUpdateCount() will return the correct number of updated rows.
    4. If the UPDATE is followed by a SELECT (see above) then callablestatement.getUpdateCount() will return ZERO even though rows were updated.
    5. I tested it with the stored proc doing SELECT - UPDATE - SELECT and again getUpdateCount() returns ZERO.
    6. I tested it with the stored proc doing SELECT - UPDATE - SELECT - UPDATE and this time getUpdateCount() returns the number rows updated by the last UPDATE and not the first.
    My Setup:
    Mac OS X 10.3.9
    Java 1.4.2
    mysql database 5.0.19
    mysql-connector 5.1.10 (connector/J)
    Maybe I have exposed a bug in JDBC?
    Thanks for your help.

    plica10 wrote:
    Jschell thank you for your response.
    I certainly don't mean to be rude but I often get taken that way. I like to state facts as I see them. I'd love to be proved wrong because then I would understand why my code doesn't work!
    Doesn't matter to me if you are rude or not. Rudeness actually makes it more entertaining for me so that is a plus. Nothing I have seen suggests rudeness.
    In response to your post:
    When a MySql stored procedure has multiple sql statements such as SELECT and UPDATE these statements each produce what the Java API documentation refers to as 'results'. A Java class can cycle through these 'results' using callableStatement dot getMoreResults(), getResultSet() and getUpdateCount() to retrieve the resultset object produced by Select queries and updateCount produced by Inserts, Deletes and Updates.
    As I read your question it seems to me that you have already proven that it does not in fact do that?
    You don't have to read this but in case you think I'm mistaken, there is more detail in the following website under the heading 'Using the Method execute':
    http://docsrv.sco.com/JDK_guide/jdbc/getstart/statement.doc.html#1000107
    Sounds reasonable. But does not your example code prove that this is not what happens for the database and driver that you are using?
    Myself I dont trust update counts at all since, in my experience some databases do not return them. And per other reports sometimes they don't return the correct value either.
    So there are two possibilities - your code is wrong or the driver/database does not do it. For me I would also question whether in the future the driver/database would continue to behave the same if you did find some special way to write your SQL so it does do it. And of course you would also need to insure that every proc that needed this would be written in this special way. Hopefully not too many of those.
    So this functionality is built into java but is not in common use amongst programmers. My java class did successfully execute a stored proc which Selected from and then finally Updated a table. My code displayed the contents of the Select query and told me how many rows were affected by the update.
    It isn't "built into java". It isn't built into jdbc either. If it works at all then the driver and by proxy the database are responsible for it. I suspect that you would be hard pressed to find anything in the JDBC spec that requires what that particular link claims. I believe it is difficult to find anything that suggests that update counts in any form are required.
    So you are left with hoping that a particular driver does do it.
    I suppose it is rare that you would want to do things this way. Returning rowcounts in OUT parameters would be easier but I want my code to be modular enough to cover the situation where a statement may return more than one ResultSet object, more than one update count, or a combination of ResultSet objects and update counts. The sql may need to be generated dynamically, its statements may be unknown at compile time. For instance a user might have a form that allows them to build their own queries...
    Any time I see statements like that it usually makes me a bit uncomfortable. If I am creating data layers I either use an existing framework or I generate the code. For the latter there is no generalization of the usage. Every single operation is laid out in its own code.
    And I have in fact created generalized frameworks in the past before. I won't do it again. Benefits of the other idioms during maintenance are too obvious.

  • Synchronous JDBC adapter(receiver side) with stored procedure

    Hi experts,
    Can some database processing logic be included in receiver JDBC (synchronous) adapter...to put it simply
    I have synchronous JDBC adapter in the receiver side..Using this JDBC adapter I want to get some response back from the table..
    The requirement is not a simple fetch from the table..It involves some processing in the database side which I guess will be done by stored procedure..After this database processing , this output will be picked up by the JDBC adapter and will send to PI.
    How can this be achived ..Any Blog..
    Thanks
    Ayan

    Yes u can use stroed procedure and send back the response,
    refer this link for stored procedure structure.
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    chirag.

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

Maybe you are looking for

  • Export in Discoverer 11g

    Hello , I have a Problem with the Web-Version of Oracle-Discoverer. I make an Export in Web-Discoverer 11g. My Result has 700 000 records and if I export this into for example a Text file then I get 177 000 records in this file. Not enough. The same

  • Configuration for 3rd party/individual PO/Intercompany sales

    Hi, Can you kindly please let me know the configuration steps (SPRO) and master data setup for the following processes? 1 - Third Party Shipment 2 - Individual PO for SD 3 - Intercompany sales. I checked in help portal but it does not help. Please sh

  • Video playback is muffled

    Video playback is muffledD I have a Sound Blaster X-Fi Titanium sound card. Music and sound effects from Window 7 seem to play fine. I don't notice any quality issues from the playback. But, if I play a video from email, go to You-Tube or even play a

  • Parameterization  in ecatt

    hi, Is Parameterization  require in ecatt ? when we transfer catt to ecatt . supriya.

  • Lightroom 3 crash on import in ui.dll

    I've been using the beta and now have a licensed version of Lightroom 3. Suddenly it has decided that it can't import photos from my card and will crash in ui.dll. I've tried multiple times without success. I don't know what changed because I have be