Updating record using toplink

Hi,
By registering the populated java object with the unit of work will insert a new record in the database.How about updating an existing record using UOW?
If any sample code, it will be very helpful.
thanks
vasu

http://otn.oracle.com/products/ias/toplink/technical/unitOfWorkWP.pdf
http://otn.oracle.com/products/ias/toplink/index.html
http://download-west.oracle.com/docs/cd/B10464_01/index.htm

Similar Messages

  • Update Query using Toplink

    I would like to fire an update query using Toplink mapping objects. The
    structure of the Query would be like
    update <<table name>>
    set <<col name A>> = 'Y'
    where <<col name B>> in (<<valA>>,<<valB>>............);
    ValA, ValB.... are dynamic values passed from my front end Java App
    Can anyone help me in this regard...........
    Thanks
    Karthik

    Karthik,
    This is new functionality added in 10.1.3. You will want to look at UpdateAllQuery.
    Doug

  • Update record using SQL statement

    I have VB6.0 and Oracle 10G Express Edition in Windows 2000 Server. My procedure in VB 6.0 can't update record in the table using SQL statement, and the Error Message is " Missing SET keyword ".
    The SQL statement in VB6.0 look like this :
    General Declaration
    Dim conn as New ADODB.Connection
    Dim rs as New ADODB.Recordset
    Private Sub Command1_Click()
    dim sql as string
    sql = " UPDATE my_table " & _
    " SET Name = ' " & Text3.Text & " ' " & _
    " AND Unit = ' " & Text2.Text & " ' " & _
    " WHERE ID = ' " & Text1.Text & " ' "
    conn.Execute (sql)
    Private Sub Form Load()
    Set conn = New ADODB.Connection
    conn.Open "Provider=MSDASQL;" & "Data Source=my_table;"& "User ID =marketing;" & "Password=pass123;"
    I'm sorry about my language.
    What's wrong in my SQL statement, I need help ........ asap
    Best Regards,
    /Harso Adjie

    The syntax should be
    UPDATE TABLE XX
    SET FLD_1 = 'xxxx',
    FLD_2 = 'YYYY'
    WHERE ...
    'AND' is improperly placed in the SET.

  • Updated records using Dynamic FORMS_DDL

    Hello everybody:
    I need help for you guys. I'm working with Form9i and created a push button that when I press it, it should be updated some record depending of some conditions. I read that with dynamics FORMS_DDL, I can able to perform it, but when I put the below code in the “WHEN-BUTTON-PRESSED” trigger I get an “Error” that meaning that the forms was not success. Please, somebody tell me where is the error. Thanks.
    if (:CONTROL_BTN.CHK_FINAL = 'N') then
         forms_ddl('update aapt_checklists
                                            set achk_reviewed_date = ' || :CONTROL_BTN.DATE_LETTER ||
    ' where achk_item in (select achk_item
                                            from aapt_checklists, aapt_reviews
                             where ' || :global.where_updated ||
    ' and achk_reviewed_date is null
    and achk_1st_notification_date is null
    and arev_seq = achk_arev_seq)     
    and achk_1st_notification_date is null
    and achk_reviewed_date is null');
    end if;
    if (form_success) then
         message('OK');
    else     
    message('Error');
    end if;

    You don't need dynamic SQL for that. Here is what you can do (Note the new v_fmt variable, and the update SQL below):
    DECLARE
      def_where varchar2(500) := NULL;
      v_month varchar2(2)   := :CONTROL_BLOCK.Q_MONTH;
      v_day   varchar2(2)   := :CONTROL_BLOCK.Q_DAY;
      v_year  varchar2(4)   := :CONTROL_BLOCK.Q_YEAR;
      v_fmt   varchar2(10);
      v_date varchar2(20) := NULL;
    PROCEDURE check_date (in_date IN varchar2) IS
      al_id     Alert;
      al_button Number;
      temp_date date := NULL;
    BEGIN
      temp_date := to_date(in_date, 'MM/DD/YYYY');
    EXCEPTION
      when others then
        al_id := Find_Alert('CFG_ERROR');
        Set_Alert_Property(al_id, alert_message_text, 'You have selected an Invalid Date');
        al_button := Show_Alert( al_id );
        raise FORM_TRIGGER_FAILURE;
    END;
    BEGIN
      -- Criteria entered as MM/DD/YYYY
      if (v_month <> '00') and (v_day <> '00') and (v_year <> '0000') then
        v_date := v_month||'/'||v_day||'/'||v_year;
        v_fmt  := 'MM/DD/YYYY';
        check_date (v_date);
      -- Criteria entered as MM/DD
      elsif (v_month <> '00') and (v_day <> '00') and (v_year = '0000') then
        v_date := v_month||'/'||v_day;
        v_fmt  := 'MM/DD';
        check_date (v_date||'/'||'2000'); -- Hardcoded 2000 to check all possible MM/DD combos including Leap Year
        def_where := ' to_char(arev_appl_received_date, ''MM/DD'') = ''' || v_date || '''';
      -- Criteria entered as MM/YYYY
      elsif (v_month <> '00') and (v_day = '00') and (v_year <> '0000') then
        v_date := v_month||'/'||v_year;
        v_fmt  := 'MM/YYYY';
        def_where := ' to_char(arev_appl_received_date, ''MM/YYYY'') = ''' || v_date || '''';
      -- Criteria entered as MM
      elsif (v_month <> '00') and (v_day = '00') and (v_year = '0000') then
        v_date := v_month;
        v_fmt  := 'MM';
        def_where := ' to_char(arev_appl_received_date, ''MM'') = ''' || v_date || '''';
      -- Criteria entered as DD/YYYY
      elsif (v_month = '00') and (v_day <> '00') and (v_year <> '0000') then
        v_date := v_day||'/'||v_year;
        v_fmt  := 'DD/YYYY';
        def_where := ' to_char(arev_appl_received_date, ''DD/YYYY'') = ''' || v_date || '''';
      -- Criteria entered as DD
      elsif (v_month = '00') and (v_day <> '00') and (v_year = '0000') then
        v_date := v_day;
        v_fmt  := 'DD';
        def_where := ' to_char(arev_appl_received_date, ''DD'') = ''' || v_date || '''';
      -- Criteria entered as YYYY
      elsif (v_month = '00') and (v_day = '00') and (v_year <> '0000') then
        v_date := v_year;
        v_fmt  := 'YYYY';
        def_where := ' to_char(arev_appl_received_date, ''YYYY'') = ''' || v_date || '''';
      end if;
      update aapt_checklists
        set achk_reviewed_date = :CONTROL_BTN.DATE_LETTER
        where achk_item in
        in (select achk_item
                from aapt_checklists, aapt_reviews
                where to_char(arev_appl_received_date,v_fmt) = v_date
                    and achk_reviewed_date is null
                    and achk_1st_notification_date is null
                    and arev_seq = achk_arev_seq)
            and achk_1st_notification_date is null
            and achk_reviewed_date is null;
      --Condition for updated records in aapt.checklists table
      :global.where_updated := def_where;
      --Only when "INCOMPLETE - NEED ADD'L INFO" Status is selected
      def_where := def_where || ' and arev_status = 1427';
    END;

  • UPDATE records using Database Conectivity toolset

    I´m using LabVIEW 8.5 & Database Connectivity toolset ver 1
    When I try to update a record of a MS ACCESS 2003 with the SQL UPDATE TablenName SET field1=newvalue, field2=newvalue........WHERE condition=x, I get the error -2147217900 Exception occurred in Microsoft Jet DataBase engine: Sintax error in the instruction UPDATE.vi ComExec (8.5 bug Workaround)vi.
    I ´dont think I have made a sintax error. If the field is an string I use the 'newvalue' following by a comma, in case of numeric field just the coma. For instance :
    UPDATE TableName SET Name='John', Age=22,Hair='blond' WHERE height=1.85
    I have discarded the reserved word´s problem, as I can insert records in the data base without any problem 
    Any idea to solve the problem
    Thanks
    Simbani

    Did you try it like this?
    UPDATE TableName SET TableName.Name='John', TableName.Age=22,TableName.Hair='blond' WHERE TableName.height=1.85

  • Updating record using table contorl

    hi ABAPers,
    i have a problem while updating the record to a database table from table control,
    please,check the code writtern,
    Code in Top include:
    Tables: MARA,
            MAKT.
    DATA: BEGIN OF ITAB OCCURS 0,
          MATNR LIKE MARA-MATNR,
          SPRAS LIKE MAKT-SPRAS,
          MAKTX LIKE MAKT-MAKTX,
          END OF ITAB.
    *data:ok_code(20).
    CONTROLS TC1 TYPE TABLEVIEW USING SCREEN 2000.
    *DATA: cols LIKE LINE OF TC1-cols,
         lines TYPE i.
    Screen_1000:Code in PAI:
    module USER_COMMAND_1000 input.
    CASE SY-UCOMM.
    WHEN 'DISPLAY'.
    SELECT SPRAS MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR = MARA-MATNR.
    IF SY-DBCNT IS INITIAL.
    MESSAGE I127(ZKC_MSGCLS).
    ELSE.
    SET SCREEN 2000.
    ENDIF.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    SET SCREEN 0.
    ENDCASE.
    endmodule.                 " USER_COMMAND_1000  INPUT
    Screen_2000:Code in PBO:
    module ctrl_pai output.
    MOVE-CORRESPONDING ITAB TO MAKT.
    endmodule.                 " ctrl_pai  OUTPUT
    Screen_2000:Code in PAI:
    module USER_COMMAND_2000 input.
    CASE SY-UCOMM.
    WHEN 'UPDATE'.
       LOOP AT TC1-cols INTO cols WHERE index GT 2.
           IF  cols-screen-input = '0'.
             cols-screen-input = '1'.
           ELSEIF  cols-screen-input = '1'.
             cols-screen-input = '0'.
           ENDIF.
           MODIFY TC1-cols FROM cols INDEX sy-tabix.
         ENDLOOP.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    SET SCREEN 0.
    WHEN 'BACK'.
    SET SCREEN 1000.
    ENDCASE.
    endmodule.                 " USER_COMMAND_2000  INPUT
    Screen_2000:Code outside PBO
    LOOP AT itab WITH CONTROL TC1 CURSOR TC1-TOP_LINE.
      MODULE ctrl_pai.
    ENDLOOP.
    Screen_2000:Code outside PAI
    LOOP AT itab.
    ENDLOOP.
    regards,
    vinod

    Hi,
    Go thro' the coding in this link.It will help you.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table%20control%20in%20abap.pdf
    Message was edited by:
            Jayanthi Jayaraman

  • How can I  delete and update records using where conditions?

    I want to delete and update the coherence records with some conditions, I describe it to use SQL as follows:
    delete from "contacts" where getStreet() = "dsada";
    update contacts set getStreet() = "dddd" where getCity() = "ssss";
    Can I use the filter like query to achieve this requirement as follows:
    ValueExtractor::View vHomeStateExtractor = ChainedExtractor::create(
    ChainedExtractor::createExtractors("getHomeAddress.getState"));
    Object::View voStateName = String::create("MA");
    Set::View setResults = hCache->entrySet(
    EqualsFilter::create(vHomeStateExtractor, voStateName));
    I know I can use get and put to achieve this requirement , but it Requires a two-interaction between the client and coherence server. Does it have And another way?
    Thanks very much, and please Forgive my English is not very good.

    Hi,
    You have a couple of options for updating or deleting using a Filter.
    For deleting you can use an Entry Processor and the cache invokeAll method. Using "out of the box" Coherence you can use the ConditionalRemove entry processor. I'm a Java person so the C++ below might not be exactly right but you should get the idea.
    ValueExtractor::View vHomeStateExtractor = ChainedExtractor::create(
    ChainedExtractor::createExtractors("getHomeAddress.getState"));
    Object::View voStateName = String::create("MA");
    hCache->invokeAll(EqualsFilter::create(vHomeStateExtractor, voStateName),
    ConditionalRemove::create(AlwaysFilter.getInstance());For update you would either need to write custom Entry Processor implementations that perform the updates you require or you can use out of the box POF or Reflection ValueUpdaters that update specific fields of the entries in the cache. These valueUpdaters would be wrapped in an UpdaterProcessor so the call would be very similar to the code above.
    JK

  • JDBC- How Update record using preparedStatement() into  MS Access?

    Actually i got an error when i update the record,The setString() Parameter are stored in terms of arrays .
    The Error is
    ErrorSQL3.java.sql.SQLException:[Microsoft][ODBC Microsft Access Driver] Syntax Error in UPDATE Statement

    Actually i got an error when i update the record,The
    setString() Parameter are stored in terms of arrays
    The Error is
    ErrorSQL3.java.sql.SQLException:[Microsoft][ODBC
    Microsft Access Driver] Syntax Error in UPDATE
    Statement
    Believe the error message - your SQL syntax is wrong.
    Either fix it or post what you have and get some advice.
    %

  • Update records using Pl/Sql procedure

    Hi
    I have wriitten a stored procedure to update the Organisation_Name in a table based on the Full_Org_Nm of an another table.
    Though the procodure got executed sucessfully but it is not updating the records.
    I even tried executing the procedure by writing Execute <Procedure name>,the database got hanged.
    Please find my procedure below.
    Create or Replace
    PROCEDURE UPDT_ISSUE_USR_ROLE
    As
    Cursor cur_user_role Is
    Select a.org_id,a.user_id
    from prts_user a,issue_user_role b
    where a.user_id=b.user_id;
    v_rows_processed Number:=0;
    Begin
    For rec in cur_user_role Loop
    update Issue_user_role
    set User_org_nm=(Select full_org_nm from VW_Org where org_id=rec.org_id)
    Where Issue_User_Role.rowid in
    (select issue_user_role.rowid
    FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
    Where Issue_User_Role.Issue_Id=Issue.Issue_id
    And Issue_User_Role.Issue_id=issue_workflow.issue_id
    And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
    And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
    And Issue.Issue_id=Issue_workflow.Issue_Id
    And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And issue_workflow.primry_workflow_flag='Y'
    And issue_user_role.user_id = rec.user_id
    And issue.issue_status_id in (1636,50738,275,50737,2090)
    And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
    v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
    End Loop;
    COMMIT;
    dbms_output.enable;
    dbms_output.put_line('There were '||v_rows_processed||' rows updated');
    End;
    Please let me know where i am wrong.
    Thanks in advance.
    Cheers

    Hi Blushadow
    Now if i want to update say only 10 records at a time what should i put into my Proc?
    Please go thru my Proc below..
    CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
    As
    Cursor cur_user_role Is
    Select a.org_id,a.user_id
    from prts_user a,issue_user_role b
    where a.user_id=b.user_id;
    upd_rec cur_user_role%rowtype;
    v_rows_processed Number:=0;
    Begin
    Open cur_user_role;
    Loop
    Fetch cur_user_role into upd_rec;
    If cur_user_role%NOTFOUND
    Then
    Exit;
    Else
    update Issue_user_role
    set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
    Where Issue_User_Role.rowid in
    (select issue_user_role.rowid
    FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
    Where Issue_User_Role.Issue_Id=Issue.Issue_id
    And Issue_User_Role.Issue_id=issue_workflow.issue_id
    And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
    And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
    And Issue.Issue_id=Issue_workflow.Issue_Id
    And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And issue_workflow.primry_workflow_flag='Y'
    And issue_user_role.user_id = upd_rec.user_id
    And issue.issue_status_id in (1636,50738,275,50737,2090)
    And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
    v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
    If Mod (v_rows_processed,v_rows_processed)=10
    then
    COMMIT;
    End if;END IF;
    End Loop;
    Commit;
    dbms_output.enable(1000000);
    dbms_output.put_line('There were '||v_rows_processed||' rows updated');
    Close cur_user_role;
    End;
    I would appreciate if you can let me know any other alternative way to meet this requirment.
    Cheers
    Vineet

  • Updating records using self join or row number function

    IF OBJECT_ID('tempdb..#Temp') IS NOT NULL DROP TABLE #Temp
    GO
    CREATE TABLE #Temp
    ID INT
    , CYear INT
    , Val INT
    , Descrp Varchar(10) NULL
    , Cd INT
    , ToBeUpdated Varchar(5) NULL
    INSERT INTO #Temp
    ID
    , CYear
    , Val
    , Descrp
    , Cd
    , ToBeUpdated
    SELECT 2014, 2013, 111, 'ABC', 2, NULL
    UNION
    SELECT 2014, 2014, 111, 'XYZ', 2, NULL
    UNION
    SELECT 2014, 2014, 222, 'TTT', 3, NULL
    UNION
    SELECT 2014, 2013, 333, 'ZZZ', 4, NULL
    UNION
    SELECT 2014, 2014, 333, 'VVV', 5, NULL
    SELECT * FROM #Temp
    ORDER BY Val, CYear
    All, I have the above #table. You'll notice that there are duplicate values in "Cd" column i.e. "Cd=2".
    If the values in ID, Val and Cd are same then, I want to update the "CodeFlag" column for those records with "Descrp" column of
    the recent CYear. So, my "ToBeUpdated" column would have a value of "XYZ" for both the records where Cd=2 (Since, XYZ is the Descrp for CYear 2014(the latest one))
    Also, if the values in ID and Val column are same but values in "Cd" is different, then ToBeUpdated = Descrp of that particular record. In my case the "ToBeUpdated" value for Cd=4 would be "ZZZ" and for Cd=5, it would be "VVV"
    since the ID and Val column values are same for those records. Let me know if you have any questions.

    IF OBJECT_ID('tempdb..#Temp') IS NOT NULL DROP TABLE #Temp
    GO
    CREATE TABLE #Temp
    ID INT , CYear INT , Val INT , Descrp Varchar(10) NULL , Cd INT , ToBeUpdated Varchar(5) NULL)
    INSERT INTO #Temp
    ID , CYear , Val , Descrp , Cd , ToBeUpdated)
    SELECT 2014, 2013, 111, 'ABC', 2, NULL
    UNION
    SELECT 2014, 2014, 111, 'XYZ', 2, NULL
    UNION
    SELECT 2014, 2014, 222, 'TTT', 3, NULL
    UNION
    SELECT 2014, 2013, 333, 'ZZZ', 4, NULL
    UNION
    SELECT 2014, 2014, 333, 'VVV', 5, NULL
    ;with mycte as (SELECT *, row_number() Over(partition By ID, Val , Cd order by CYear DESC) rn
    , row_number() Over(partition By ID, Val order by Descrp) rn1
    FROM #Temp)
    SELECT m1.ID ,m1.CYear,m1.Val,m1.Descrp , ToBeUpdated=d.descrp from mycte m1
    Cross apply (Select Top 1 descrp from mycte m2 WHERE m2.id=m1.ID AND m1.Val=M2.Val AND m1.cd=m2.cd AND m1.rn>=m2.rn) d(descrp)

  • Updating records using a view

    Hello,
    I have two tables, ROAD and ROAD_PARSED. I have created a view ROAD_V that contains the fields from ROAD and ROAD_PARSED that I want to to update in ROAD.
    CREATE VIEW ROAD_V AS SELECT A.ID, A.PREF, A.NAME, A.TYPE, A.DIR,  B.PREF "BPREFIX", B.NAME "BNAME",  B.TYPE "BTYPE", B.DIR "BDIR"
    FROM ROAD A, ROAD_PARSED B
    WHERE A.ID=B.ID;
    Then I entered my update statement: UPDATE ROAD_V SET PREF=BPREFIX, NAME=BNAME, TYPE=BTYPE, DIR=BDIR;
    I got this error: +"ORA-01779: cannot modify a column which maps to a non key-preserved table".+ ROAD has a spatial index on ID and ROAD_PARSED has a unique on ID, and there are not other unique fields in my table. How do I go about adding a unique index to ROAD when i have already indexed ID?
    The only thing I can think of to work around it is to create a new field in ROAD, populate it with a sequence starting at 1 and assign a unique index to it, insert those values into ROAD_PARSED, and then run the update. This sounds unnecessary...but is it the right way?

    Hi Beaver,
    You can find examples and explanations regarding your error here:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:548422757486
    and/or
    http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22ORA-01779%22

  • Shot Dump while updating record in ETTIFN using the FM ISU_DB_ETTIFN_UPDATE

    Hi All,
    Am getting shot dump while trying to update an entry in ETTIFN database table using the FM ISU_DB_ETTIFN_UPDATE.
    If this FM fails to update then it tries to  raise error message using the macro 
    MAC_MSG_PUTX CO_MSG_PROGRAMMING_ERROR '016' 'E9'
           'ETTIFN' SPACE SPACE SPACE
           SPACE .
    Runtime Errors         MESSAGE_TYPE_X
    Error analysis
        Short text of error message:
        Error in changing table ETTIFN
        Long text of error message:
         Diagnosis
             An error occurred when one or more table entries were being
             changed. This error was reported by the database system.
         System Response
             The system does not permit changes to one or more table entries.
             It is possible that an SAP short dump has been written from the SAP
             basis system.
         Procedure
             Find out if the SAP short dump provides additional information.
             You can view SAP short dumps using Transaction SM21.
        Technical information about the message:
        Message class....... "E9"
        Number.............. 016
        Variable 1.......... "ETTIFN"
        Variable 2.......... " "
        Variable 3.......... " "
        Variable 4.......... " "
    Please advice inorder to fix the same.
    Regards,
    Deepthi

    Hi Deepthi,
    Updating database using statement update can give dumps because of below issues:
    "At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table."
    I would rather suggest you to call the FM in Mode 'M', i.e. Modify so if entry in table is not there to update, it will insert that record and also won't give dump.
    Thanks.
    Ravi

  • Updating a persons name using toplink uow

    Hi,
    I am having problems updating the name of a PERSON. I am using Toplink with a SessionBeanFacade.
    I am using a Backing Bean, which is calling the Session Bean Facade. I was debugging the code and the strange thing is: I can see the updated name in the entity and in the uow, but after uow.commit the updated name isn't in the database. Why won't the values from the uow persist?
    SESSION BEAN FACADE
      public Object mergeEntity(Object entity) {
        UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
        Object workingCopy = uow.readObject(entity);
        if (workingCopy == null)
          throw new RuntimeException("Could not find entity to update");
        uow.deepMergeClone(entity);
        uow.commit();
        return workingCopy;
    BACKING BEAN
      public void recoverBusinesspartner(ActionEvent actionEvent) {
        DCBindingContainer dcBind = (DCBindingContainer)getBindings();
        DCIteratorBinding iterBind = (DCIteratorBinding)dcBind.get("personIterator");
        iterBind.getCurrentRow().setAttribute("name", "Bodhy");
        dcBind.getOperationBinding("mergeEntity").execute();
      }Thank you
    Bodhy
    Edited by: Bodhy on 30.09.2008 06:02
    P.S. I don't get any errors or some other message in my log. I am using JDeveloper 11g TP3

    Hello,
    Glad you found the problem. As I mentioned in my previous post, you should not be modifying objects from the session cache. When you do any sort of query on a session other than a UnitOfWork, the objects returned exist in the shared session cache. When you register an object, the state of the object is pulled from the session cache and used for a comparison - TopLink will think that is the state the database is in.
    This is why Detach resolves the issue- it makes a copy of the object so that changes to it do not get put into the cached copy.
    I would recommend looking at:
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/cachun001.htm
    and
    http://www.oracle.com/technology/products/ias/toplink/technical/unitOfWorkWP.pdf
    to see how caching and the UOW work in TopLink
    Best Regards,
    Chris

  • Updating a record using pay element using the API (Almost Done)

    Hi Everyone,
    I have a question about updating a record using the PAY_ELEMENT_ENTRY_API.update_element_entry
    I have process that doesn't error out, but its doesn't seem to update the record. So my question is, is the query below the correct way to get the element name and object version number when using this API? If not, what do I need to do?
    BEGIN
    SELECT MAX(pee.element_entry_id)
    INTO x_element_id_mgr
    FROM pay_element_types_f pet,
    pay_element_links_f pel,
    pay_element_entries_f pee,
    per_all_assignments_f paaf,
    per_all_people_f papf
    WHERE pee.element_link_id = pel.element_link_id
    AND pel.element_type_id = pet.element_type_id
    AND paaf.assignment_id = pee.assignment_id
    AND papf.person_id = paaf.person_id
    AND pet.element_name = 'Mgr Rec Pct'
    AND sysdate BETWEEN pee.effective_start_date AND pee.effective_end_date
    AND sysdate BETWEEN pel.effective_start_date AND pel.effective_end_date
    AND sysdate BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    AND sysdate BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND paaf.assignment_id = c_staging.assignment_id
    AND papf.person_id = c_staging.person_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    --ROLLBACK TO s1;
    v_error_message := 'For employee number '||c_staging.employee_number||' No data found for element name Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    WHEN OTHERS THEN
    --ROLLBACK TO s1;
    v_error_message := 'For employee number '||c_staging.employee_number||' Error found for element name Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    END;
    --- Get OVN
    BEGIN
    SELECT MAX(Object_version_number)
    INTO x_ele_object_version_number
    FROM pay_element_entries_f
    WHERE element_entry_id = x_element_id_mgr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    v_error_message := 'For employee number '||c_staging.employee_number||' Error in getting the OVN for Mgr Rec Pct ' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    WHEN OTHERS THEN
    v_error_message := 'For employee number '||c_staging.employee_number||' Error in getting the OVN for Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    END;

    Your SQL isn't bad, although you're including loads of tables you don't need to so it's probably not as fast as it could be. I'm not sure you know what element entry to update so let's look at an example:
    -- | Element Entry Id | OVN | Start Date | End Date    | Pay Value |
    -- +------------------+-----+------------+-------------+-----------+
    -- | 123                2    1-Jan-2009   31-Jan-2011   USD 400
    -- | 123                1    1-Feb-2009   18-Jun-2011   USD 500
    -- | 123                1    19-Jun-2011  25-Jun-2011   USD 600
    -- | 123                5    26-Jun-2011  31-Dec-4712   USD 700Here the one element entry (Id 123) has 4 effective rows. The employee gets $400 in Jan 2009, $500 from Feb 2009 to mid-June 2011, $600 for a few days later in June 2011 and then $700 from 26th June 2011 onwards.
    So your question to the forum is which one do I update. Well, that depends which one you want to update. If you want to update the 1st Jan 2009 to 31st Jan 2011 you'd pass element_entry_id => 123, ovn => 2, effective_date => to_date('1-Jan-2009', 'DD-MON-YYYY') and datetrack_mode => 'CORRECTION'.
    If you wanted to update the $700 row you'd pass OVN 5 and an effective date of 26th June 2011. And so-on.
    Now in your SQL you're filtering based on sysdate, which means you'd be updating the $500 row (ovn=1). Is that what you want?
    I have simplified your SQL as follows:
    SELECT pee.element_entry_id
          ,pee.object_version_number
    INTO   x_element_id_mgr
          ,x_ele_object_version_number
    FROM   pay_element_entries_f pee
          ,pay_element_types_f pet
    WHERE  pee.assignment_id = c_staging.assignment_id
    AND    pee.element_type_id = pet.element_type_id
    AND    pet.element_name = 'Mgr Rec Pct'
    AND    trunc(sysdate) BETWEEN
           pee.effective_start_date AND pee.effective_end_date
    AND    trunc(sysdate) BETWEEN
           pet.effective_start_date AND pet.effective_end_date;This selects both the entry Id and OVN in one go; there's no need to have 2 SQL statements. If multiple entries are allowed, this SQL could return more than one row so just watch out for that. If you don't want the row as of sysdate change the two sysdate joins accordingly.
    I hope that helps.

  • How to update bulk no of records using  Batch Update

    i am trying to insert and update records into multiple tables using Statement addBatch() and executeBatch() method. But some times it is not executing properly. some tables records are inserting and some tables it is not inserting. But I want all the records need to excute and commit or if any error is there then all records need to rollback.
    This is the code i am using.
    public String addBatchQueryWithDB(StringBuffer quries, Connection conNew,Statement stmtNew) throws Exception {
    String success="0";
    try {         
    conNew.setAutoCommit(false);
    String[] splitquery=quries.toString().trim().replace("||","##").split("\\|");
    for(int i=0;i<splitquery.length;i++) {
    //System.out.println("query.."+i+".."+splitquery.trim().replace("##","||"));
    stmtNew.addBatch(splitquery[i].trim().replace("##","||"));
    int[] updCnt = stmtNew.executeBatch();
    for(int k=0;k<updCnt.length;k++){
    int test=updCnt[k];
    if(test>=0){
    success=String.valueOf(Integer.parseInt(success)+1);
    // System.out.println(".updCnt..."+updCnt[k]);
    System.out.println("success...length.."+success);
    if(updCnt.length==Integer.parseInt(success)){
    success="1";
    //conNew.commit();
    } catch (BatchUpdateException be) {
    //handle batch update exception
    int[] counts = be.getUpdateCounts();
    for (int i=0; i<counts.length; i++) {
    System.out.println("DB::addBatchQuery:Statement["+i+"] :"+counts[i]);
    success="0";
    conNew.rollback();
    throw new Exception(be.getMessage());
    } catch (SQLException ee) {
    success="0";
    System.out.println("DB::addBatchQuery:SQLExc:"+ee);
    conNew.rollback();
    throw new Exception(ee.getMessage());
    } catch (Exception ee) {
    success="0";
    System.out.println("DB::addBatchQuery:Exc:"+ee);
    conNew.rollback();
    throw new Exception(ee.getMessage());
    }finally {
    // determine operation result
    if(success!=null && success.equalsIgnoreCase("1")){
    System.out.println("commiting......");
    conNew.commit();
    }else{
    System.out.println("rolling back......");
    success="0";
    conNew.rollback();
    conNew.setAutoCommit(true);
    return success;
    }

    Koteshwar wrote:
    Thank you for ur reply,
    I am using single connection only, but different schemas. Then I am passing a Stringbuffer to a method, and First iam setting con.setAutoCommit(false); and then in that method i am splitting my queries in stringbuffer and adding it to stmt.addBatch(). After that I am executing the batch.after executing the batch i am commiting the connectionIf I am reading that right then you should stop using Batch.
    The intent of Batch is that you have one statement and you are going to be using it over and over again with different data.

Maybe you are looking for

  • Data in XML format (XML files) to BW?

    Hi, My customer is interested in loading data to BW (from 3rd party system) in XML format. Are there any advantages of doing this (compared to traditional ascii files)? How about disadvantages (BW version is 3.5) ?. How to get started with this one,

  • How to clean large system log files?

    I believe that OS X saves a lot of system data in log files that become very large. I would like to clear old history logs. How may I view and clean system log files?

  • Unpivot taking the last letter from the column name

    Hi guys, having DATE               Period1 Period2 Period3 Period4 01/01/2014       1.02       1.06      1.02      1.03 02/01/2014       1.06       1.05      1.04      1.06 I would like an unptivot as 01/01/2014    1        1.02 01/01/2014    2      

  • No sound after installing window 8.1 on HP620 (64bits)

    Hi, please i need help. After installing window 8.1 on HP 620, i reinstalled all drivers but yet, No sound. i"ve checked device manager and all sound drivers seems to be working properly but i cant still hear anything. please i need help

  • IWDPDFDocumentCreationContext Interface - no static text rendered

    WebDynPro java.  Netweaver 2004s Adobe LiveCycleDesigner 7.1 I believe (how can I confirm?) I am using the IWDPDFDocumentCreationContext to render a non-interative PDF form.  When the pdf is rendered, none of the static text, horizontal lines, page h