Can getGeneratedKeys() be used when executing batches of statements?

Hi all,
this question was posted in this thread:
Can getGeneratedKeys() be used when executing batches of statements?
but unfortunately I didn't find the answered appropriate.
That thread is now locked, so I would like to start it again here.
This is a summary of the other thread:
Can you retrieve keys generated by a batch of insert statements? The following code produces an ArrayIndexOutOfBoundsException from the Oracle T4CNumberAccessor.unmarshalOneRow() method (see stack trace at the bottom of this message).
The code is:
String sql = "INSERT INTO FOO (ID, NAME) VALUES (FOO_SEQ.NEXTVAL, ?)";
String generatedColumns[] = {"ID"};
PreparedStatement pstmt = connection.prepareStatement(sql, generatedColumns);
pstmt.setString(1, "A");
pstmt.addBatch();
pstmt.setString(1, "B");
pstmt.addBatch();
pstmt.setString(1, "C");
pstmt.addBatch();
//EXCEPTION OCCURS HERE
pstmt.executeBatch();
The exception is:
java.lang.ArrayIndexOutOfBoundsException: 22
at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow(T4CNumberAccessor.java:190)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:610)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10580)
The only answer given was:
"You should directly specify how big your batching is. For that reason you may use ExecutionContext where you can set setBatchingLimit(int) and setBatching(bool). This operation will tell execution context the size of supposed batching and also should be batching performed at all or not. You can add batching jobs but you can not execute the jobs without proper initialization of batching job size - it will fail with out of bounds."
ExecutionContext is not something I found in jdbc drivers, so I'm a bit confused about this answer.
Did anyone solve the problem?
Thanks,
Michele

>
We have the same problem. No solution so far.
>
I never found a definitive solution but testing seems to show that this is not possible.
There is no code that can be written to get the generated keys if batching is used.
This is because the 'getGeneratedKeys' method must be called on the prepared statement and would return the generated keys as a ResultSet object. But when batching there is only one prepared statement but multple sets of parameters, one for each batch entry.
Thus there could only be one call to 'getGeneratedKeys' since there is only one prepared statement. This strongly implies that it is not possible to use 'getGeneratedKeys' when batching.
See Retrieval of Auto-Generated Keys in the JDBC Dev guide
http://docs.oracle.com/cd/B19306_01/java.102/b14355/jdbcvers.htm#CHDEGDHJ

Similar Messages

  • How can i know which index will be used when executing the query ?

    1 ) I have query in which i have 3-4 tables but there multiple index on one column .
    so how can i know which index will be used when executing the query ?
    2) I have a query which ia taking too much time . how can i know which table is taking too much time ?
    3) Please Provide me some document of EXplain plan ?

    Hi Jimmy,
    Consider the below example
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    CREATE TABLE FIRST AS
    SELECT * FROM all_objects;
    UPDATE FIRST
    SET object_name = 'TEST'
    WHERE owner != 'SCOTT';
    CREATE INDEX idx_first ON FIRST(object_name);
    SELECT *
    FROM FIRST
    WHERE object_name = 'TEST';
    It has not used index
    Execution Plan
    Plan hash value: 2265626682
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 58678 | 7334K| 163 (4)| 00:00:02 |
    |* 1 | TABLE ACCESS FULL| FIRST | 58678 | 7334K| 163 (4)| 00:00:02 |
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    SELECT *
    FROM FIRST
    WHERE object_name = 'emp';
    This has used the index
    Execution Plan
    Plan hash value: 1184810458
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 128 | 1 (0)| 00:00:01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| FIRST | 1 | 128 | 1 (0)| 00:00:01 |
    |* 2 | INDEX RANGE SCAN | IDX_FIRST | 1 | | 1 (0)| 00:00:01 |
    From this we can come to the conclusion that, whether to use one index or not by oracle
    would also depend on the data which is present in the table. This has to be this way as
    we see in the bind peeking, if oracle sticks to only one plan, say only use the full table
    scan, it would be a performance hit when it searches for the second query ie where object_name
    ='emp';
    2.
    If we have a query like below.
    select * from emp
    where upper(ename) = upper(:p_ename);
    Evenif we have the index on ename column, oracle wouldn't be able to use the index, as there is a function in the predicate column. If you need oracle to use the index, we need to create a function based index as below.
    Create index idx_ename on emp(upper(ename));
    Regards,
    Cool

  • AIR 3.8.0.440 / iOS: build fails with "ld: -pie can only be used when targeting iOS 4.2 or later"

    With AIR 3.8.0.440, iOS build with "adt -package -target ipa-ad-hoc" fails with a linker error:
    ld: -pie can only be used when targeting iOS 4.2 or later
    What's the correct option to suppress this error or does it need a fix for adt?
    In the app.xml,
    <key>MinimumOSVersion</key>
                <string>5.0</string>
    is already present in the iPhone InfoAdditions section.
    (Building the same app with AIR 3.8.0.370 is fine)

    Hi,
    Can you make sure that both your old ane and new ane are not present in your extensions directory.
    Also, how are you zipping/unzipping the ANE?
    If you are on a Mac, try these steps on the terminal:
    1) Create a new temp directory, say temp (mkdir temp)
    2) cd temp
    3) Copy the ane you need to make changes to into this directory.
    4) unzip nameofane.ane
    5) rm nameofane.ane
    6) Make changes to the platform.xml file using a text editor or vim
    7) cd to the temp directory again, (if you are now elsewhere)
    8) zip -r nameofane.ane .
    9) Copy the ane file created into your extensions directory, where you have placed the other extensions and then, package the IPA using adt.
    If you are on Win,
    1) Rename the .ane to .zip
    2) Extract the contents of .zip
    3) Make changes to platform.xml and save it.
    4) Go back to the directory where you extracted the files, select all the folders/files and right click to zip them back.
    5) Rename the .zip to .ane and then, package the IPA.
    It should work.

  • Session state can only be used when enablesessionstate is set to true.

    When I try to open up a certain webpage it says; Session state can only be used when enablesessionstate is set to true. What does it mean and what should I do?

    Contact the webmaster for that site and report the problem.

  • Problem with ANE - "ld: -pie can only be used when targeting iOS 4.2 or later"

    I'm trying to compile a simple AIR Mobile app for iOS, incorporating an ANE to support Localytics
    http://flashsimulations.com/2012/06/18/localytics-adobe-air-native-extension/
    Compilation fails with the message "ld: -pie can only be used when targeting iOS 4.2 or later"
    Surely 7.0 is later than 4.2! (I'm using Flex 4.6 - AIR 3.9 SDKS). Tried building with FDT and with Flash CC, and against earlier versions of the iOS SDK (6.0, 5.0).
    Any suggestions?

    thanks, but can you be more specific? Presumably I add something in this part:
        <iPhone>
            <InfoAdditions><![CDATA[<key>UIDeviceFamily</key>
                                                  <array>
                                                      <string>1</string>
                                                      <string>2</string>
                                                  </array>
                                                  <key>UIStatusBarStyle</key>
                                                  <string>UIStatusBarStyleBlackOpaque</string>
                                                  <key>UIRequiresPersistentWiFi</key>
                                                  <string>YES</string>]]></InfoAdditions>
            <requestedDisplayResolution>high</requestedDisplayResolution>
        </iPhone>

  • ASP Web Forms Error: Session state can only be used when enableSessionState is set to true

    Hello,
    I am developing a custom application page for a custom Web Forms I am creating, which I plan on using for custom task form into SharePoint 2010 Foundation.
    Currently, I am trying to test it in Debug Mode using Visual Studio 2010 but when I am trying to use Sessions I get the error:
    Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration
    I've already done this on trying to fix:
    On my page
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestForm.aspx.cs" Inherits="TestForm" EnableSessionState="True" %>
    And on my web.config
    <pages enableSessionState="true">..<httpModules>
    <remove name="Session" />
      <add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </httpModules>
    Note: I am getting an error when I try to add <module> into web.config
    ASP .NET State Service is currently running.
    And the part where it keeps error is when in PageLoad, I try to set a List object something like this:
    List<object> myobject
    get
    if (Session["object"] == null)
    Session["object"] = new List<object>();
    return Session["object"] as List<object>;
    set
    Session["object"] = value;
    protected void Page_Load(object sender, EventArgs e)
    myobject= new List<object>();
    BUT the error still persists! I also try to restart IIS but still the error still happens.
    I am running out of ideas so can you help me out?
    Thank you!

    Could be your skype intercepting your requests at 80 port, in Skype options uncheck
    Or Your IE has connection checked for Proxy when there is no proxy
    Or your fiddler could intercept and act as proxy, uncheck it!
    Solves the above problem, It solved mine!
    HydTechie
    HydPhani

  • How can I see error when  execute UPDATE with BULK COLLECT

    Hi
    I have a code
       CURSOR c_renov_eleg IS
            SELECT t2.ROWID
              FROM mytable  t2
         WHERE  BLA BLA BLA
    OPEN c_renov_eleg;
          LOOP
            FETCH c_renov_eleg BULK COLLECT
              INTO w_rowid LIMIT 1000;
            FORALL i IN 1 .. w_rowid.COUNT
              UPDATE mytable
                 SET id_baixa_elegibilidade = K_SCNOB_BXA_RENOVACAO,
                      column01         = arr_ciclo(1),
                     dt_ultima_atualizacao  = SYSDATE,
                     cd_usuario_atualizacao = USER
               WHERE ROWID = w_rowid(i);
            COMMIT;
            EXIT WHEN c_renov_eleg%NOTFOUND;
          END LOOP;How can I to sse when and where have some error ? , in Exception return what record ?

    How can I to sse when and where have some error
    ?Have a look at
    [url=http://download.oracle.com/docs/cd/B28359_01/appd
    ev.111/b28370/tuning.htm#i49099]Handling FORALL
    Exceptions (%BULK_EXCEPTIONS Attribute).btw. just never ever commit in a for loop ;)
    (Tubby is just too fast ;))
    Hi , thank all
    btw. just never ever commit in a for loopWhen I must to COMMIT using BULK COLLECT ?

  • WLST - Can it be used when AdminServer is down?

    Can you still use WL scripting when the AdminServer is unavailable?
    I'm looking for an alternative for domain management if we experience the loss of an AdminServer and prior to getting the AdminServer back online.

    yes, you can directly connect to the managed server.
    HTH,
    -satya
    BEA Blog:
    http://dev2dev.bea.com/blog/sghattu/
    Get Involved in CodeShare:
    https://wls-console-extensions.projects.dev2dev.bea.com/
    https://wlnav.projects.dev2dev.bea.com/
    https://eclipse-wlst.projects.dev2dev.bea.com/
    https://wlst.projects.dev2dev.bea.com/

  • My iPhone4S can't be used when it upgraded to 5.01!!!

    I used OTA to upgrade my phone to 5.01 but after that my phone can't call or use message. And I google it that so many people have the same problems. What's happens? My phone model is MC920LL/A.

    how did you remove iTunes? Did you uninstall only iTunes or all components? This is necessary.
    Check out this : http://support.apple.com/kb/HT1923
    Use that article and try it again.
    By the way, when you have an issue, the first thing to check is whether your software is up-to-date.

  • Can't find class when executing javabean test

    Hi,
    I've installed Sunone 6.0
    JSP is installed
    JDK is installed
    I've written and compiled a simple javabeans program
    and it generates class correctly.
    When I try to execute I get "Can't find class" error.
    Where does the class need to reside after compiling?
    Is my PATH hosed?
    Thanks for any pointer
    Willie

    hi
    did you get a chance to read this doc:
    http://docs.sun.com/source/817-6251/pwajsp.html

  • TS4337 Ever since I updated the OSX (V 10.9.1) iCal can't be used, when I open it a message pops saying: The server responded with an error, couldn't move calendars to iCloud because an error occurred. I turned off icloud and the same keeps happening.

    Mail is not functioning right, as well as iWorks. And everything started to break down since I updated the OS please help!

    To check the local network for some of the common configuration problems, launch Terminal.app and issue the following diagnostic command:
    sudo changeip -checkhostname
    That'll report some local configuration information and then either no errors detected and no changes required, or it'll point to whatever configuration errors or issues it might detect.  That doesn't catch everything, but it catches the common errors.
    FWIW, 192.168.0.0/24 and 192.168.1.0/24 are poor choices for the local network, as VPNs are based on IP routing and IP routing gets tangled when the same subnet is used on both ends of the VPN. 192.168.0.0/24 and 192.168.1.0/24 are near ubiquitous in home networks and coffee shops.

  • Can AQ be used when running in IBM's WebSphere Application Server?

    Hi,
    We are using IBM WebSphere Application Server (WAS) but not planning to use MQSeries. We want to use Oracle AQ. Is it possible to run an app in WAS with Oracle AQ functionality being used?
    Anyone out there is doing this?
    Any info. is greatly appreciated!
    Thanks.
    Alex

    If you ever find the answer, please let me know. I am trying to do the same with WebLogic but with little success. I have participated in the following discusiions:
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.jms&item=6218
    http://marvel.oracle.com/pls/otn/f?p=17000:8:25148205767784132::NO::F17000_P8_DISPLAYID,F17000_P8_CRITERIA:40460583213,
    If you are not using MDB in WAS or WAS MDB supports transacted session, then there is a good chance that you can use AQ/JMS. BTW, why don't you want to use MQ Series?

  • Are the music beds provided in iMovie copywritten or can it be used when posting to Facebook?

    I used a music bed provided with iMovie '09 into a video and tried to post it to Facebook. Later, I got a notice from Facebook claiming that the video contained copywritten material. Is the music in iMovie royalty free so that I can post it to the Internet?

    You can use it in FaceBook. I think that Apple owns the Copyrights, but you are issued a license to use them.
    You can find the legalese in this Apple Document, section 2 G iii.
    It can be tricky, because sometimes musicians will use the Apple jingles under this same license, and then copyright the results. You will have to explain to YouTube or FaceBook that you are licensed through Apple to use the track. It is usually a good idea to provide a credits page at the end of your movie AND in the description on YouTube or FaceBook detailing where you got the music and how you are licensed, but this will not keep the record companies from hassling you if one of their artists has also used the samples.

  • Can 1ROWCOUNT be used when reporting on Cubes?

    Dear Bwers,
    Can i use 1ROWCOUNT while reporting on cubes? If not is there any other alternative? Please let me know.
    Thanks
    Raj

    Hi Raj,
    Have you seen these 2 documents:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7e58e690-0201-0010-fd85-a2f29a41c7af
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
    Hope this helps...

  • Weird problem when executing an update statement

    Please help me out with this issue. This a very weird problem i'm facing while executing the following update statement.
    update tblo.S_TABLE c
    SET (ACCNT_NAME, ACCNT_LOC)
    =
    (select NAME, LOC from S_TABLE1 p
    where p.ROW_ID = c.ACCNT_ID)
    where ROW_ID = 'XXXXX'
    The statement executes perfectly fine in "SQL Plus" but when i try from my application or any SQL Tool that uses ODBC, it fails with the following error
    <eb1>ORA-00923: FROM keyword not found where expected
    State:S1000,Native:923,Origin:[Oracle][ODBC][Ora]</eb1>
    ODBC Driver Used: 9.2.0.2.0

    Yes this could most probably be resolved by upgrading the driver. I'hv tried MS Oracle ODBC driver but that is even more problematic!
    The applications works fine in another environment which uses a Merant ODBC driver. Thanks for your time and advice.

Maybe you are looking for

  • Copyright question for posting to the web

    hi all. i am wondering if someone wouldn't mind giving me a bit of expertise on a question i have. i have a set of images from various sources that are basically creative imagery. i have organized these and i would like to share them by posting them

  • Oracle Express 10g - cannot install on Windows 2003

    I'm trying to install Oracle Express 10g on Windows 2003. On this machine already works MS SQL2005 server. The installation starts ok but after copying files installer disappears whitout any message (in that moment an icon on desktop should be create

  • Encoder triggering counter capture

    Hi, I'm doing some research into how I can implement the below application. From what I've read, I'm 95% sure I can do what I want with a timer/counter card. But I figured I'd throw it out there to make sure. My application is as follows: I have (or

  • How to retrieve error information from an exception handler?

    I have an Embedded PL/SQL block in a Pro*C application that uses something like the following to catch exceptions and fill a host variable with diagnostic information. It then re-raises the exception so that the global error handler specified with a

  • Viewing Archived Workflows

    Hi People, Once I archive workflows and work items, is there any way I can see them through the normal transactions like SWI6, SWIA etc. Or can I read them only through SARA transaction?