How to choose Insert or update action in bean managed

Hello

uses: Studio Edition Version 11.1.1.6.0, JDEVADF_11.1.1.6.0_GENERIC_111205.1733.6192.1 building

I have a .jspx page that shows a table of the table db (table 1). On the page, the user can modify the data and commit the changes to db by clicking a command button. Command button triggers a java method, inside java tries to get the only edited lines and insert new db table (table 2). Use entity of table2 object for insertion in table2. I can able to insert these steps correctly.

Again once when the user changes the same line, which was just inserted in table2, I want to update the same row in the table2 recently inserted.

Insert for the first time is easy, but how to choose Insert (if it is new to table2) or update (if it already exists in table2) in consecutive calls.

Concerning

Siva

You can try to look for the line of table2 by using the method findByKey() of the ViewObject.

If findByKey() returns 1 row, this means that you need to update.

If it returns 0 rows means that you need to insert a new line.

Kind regards

Elias.

Tags: Java

Similar Questions

  • How to write insert and update blocks about with an if

    Hai All

    How to write an insert and update block education about with in an if

    I had a condition Ie

    If the time is between 0630 and 1030


    then

    Insert into Daily_attend
    ----


    Update Daily_attend set

    -----

    Concerning

    Srikkanth.M

    There is nothing preventing you to do this:

    BEGIN
      INSERT INTO x (mycolumn) VALUES ('A');
    
      UPDATE x
      SET mycolumn = 'B'
      WHERE mycolumn = 'A';
    
      COMMIT;
    END;
    /
    

    other than the fact that he seems a bit inefficient. Yet once you try to do, and why, is not clear.

    Can you put an IF statement in there to choose one way or the other under certain conditions? Yes. But I wonder if what you
    are actually trying to do is to reinvent the MERGE statement.
    http://www.morganslibrary.org/reference/merge.html

  • How do I insert or update multiple values in a field of diff files

    Hai All

    I need to insert or update or multiple values in a single diff of one field records to another table.


    Table 1 has 3 fields

    Bartime bardate barcode

    02/01/10 0011, 0815

    02/01/10 0022, 0820

    02/01/10 0011, 1130

    02/01/10 0022, 1145

    02/01/10 0011, 1230

    02/01/10 0022, 1235

    02/01/10 0011, 1645

    02/01/10 0022, 1650


    These are the times that arrives at 0815 and pauses at 1130 and arrives at 12: 30 a.m. and coming home at 4:45 pm
    These table I have to insert into another table called table2
    and the fields are bar codes, date, intrinsically timein, introut, tiomout

    And the output you want to like this

    barcode timein intrinsically introut timeout date
    0011 0815 1130 1230 1645 02/01/10

    0022 0820 1145 1235 1650 02/01/10

    If all give some good answer that it will be help full...

    Thanks and greetings

    Srikkanth.M

    Try like this

    with t
    as
    (
    select '0011' barcode,to_date('01-02-10','dd-mm-yy') bardate,'0815' bartime from dual union all
    select '0022',to_date('01-02-10','dd-mm-yy'),'0820' from dual union all
    select '0011',to_date('01-02-10','dd-mm-yy'),'1130' from dual union all
    select '0022',to_date('01-02-10','dd-mm-yy'),'1145' from dual union all
    select '0011',to_date('01-02-10','dd-mm-yy'),'1230' from dual union all
    select '0022',to_date('01-02-10','dd-mm-yy'),'1235' from dual union all
    select '0011',to_date('01-02-10','dd-mm-yy'),'1645' from dual union all
    select '0022',to_date('01-02-10','dd-mm-yy'),'1650' from dual
    )
    select barcode,
           bardate,
           max(decode(rno, 1, bartime)) timein,
           max(decode(rno, 2, bartime)) interin,
           max(decode(rno, 3, bartime)) interout,
           max(decode(rno, 4, bartime)) timeout
      from (select barcode,
                   bardate,
                   bartime,
                   row_number() over(partition by barcode, bardate order by to_date(bartime,'hh24:mi')) rno
              from t)
     group by barcode, bardate
    
  • How to choose to delete updates without installing?

    I see a lot of international languages in my windows update that I do not want to install.

    How TO hide an update [optional, non-security]...

    http://www.SevenForums.com/tutorials/24376-Windows-Update-hide-restore-hidden-updates.html

  • How to get the control instance data in Bean managed when data mutiple controls exist

    Below is my way. This works if there is only one control. is there an api that can be used to get the instance of the data control by name?

            DCDataControl dc = BindingContext.getCurrent().getDefaultDataControl();
            if(dc != null){
                AppModuleImpl am = (AppModuleImpl)dc.getApplicationModule();
               ...
             }
    

    I don't want to use this medium orginial.

          String amDef = "model.AppModule";
          String config = "AppModuleLocal";
          ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
          ViewObject vo = am.findViewObject("ObjectView1");
    

    Hello

    I guess you have a binding method as the first activity in your stubborn workflow. Open your workflow in preview mode, right-click on your connection method and say «Go to the PageDef» This will create a definition file page for the binding of your method. You can use this to put the iterator binding that you want to access from your init method.

    Rami

  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • How to choose a program to open my photos when inserting my SD card? as it doesn't give me options of this program to use differently than before, why, I don't know, so any help would be appreciated.

    How to choose a program to open my photos when inserting my SD card because it does not give me options of this program to use differently than before, why, I don't know, so any help would be appreciated.

    I know what it is, and I'm trying to answer it... will keep you posted
    your original question in a forum of Vista.

    OK... you are running XP and your computer has a media player you
    Insert the card in?

    If you go to... Start / my computer... There should be one or more readers
    listed as... Removable Disk... These are the slots of the media player.

    If you right click on the removable disk representative the memory card
    and in the menu... Choose... Properties / Autoplay tab and open the fall
    window and select pictures. And... ICT... "ask me each time to choose
    an action "." Maybe this will restore the AutoPlay window when you insert
    the map.

    You could also try... on the left by clicking on the button "Restore default settings" / apply / OK.

    And it may be worth trying to run the AutoPlay Repair Wizard.

    Download the Microsoft Autoplay Repair Wizard:
    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&ID=2648

  • How to modify and update a line later was inserted and updated in the doDML() method?

    Mr President

    Jdev worm is 12.2.1

    How to modify and update a line later was inserted and updated in the doDML() method?

    I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

    Method 1-first row in managed bean

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
            RowSetIterator rsi = dciter.getRowSetIterator();        
            Row lastRow = rsi.last();        
            int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
            Row newRow = rsi.createRow();        
            newRow.setNewRowState(Row.STATUS_NEW);        
            rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
            rsi.setCurrentRow(newRow);
            
            BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
            RowSetIterator rsi1 = dciter1.getRowSetIterator();        
            Row lastRow1 = rsi1.last();        
            int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
            Row newRow1 = rsi1.createRow();        
            newRow1.setNewRowState(Row.STATUS_NEW);        
            rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
            rsi1.setCurrentRow(newRow1); 
            
            
        }
    


    Method of doDML() of line 2 seconds in the entityImpl class


        protected void doDML(int operation, TransactionEvent e) {        
            setAmount(getPurqty().multiply(getUnitpurprice()));
           
            if (operation == DML_INSERT)  
                       {          
                         insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                           }
                           
                           if(operation == DML_UPDATE)
                           {
                               
                           updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                           }                                       
            super.doDML(operation, e);
        }
    
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
       ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                      System.out.println("sql= " + sql);    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }  
                  
                  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
       + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                      System.out.println("sql= " + sql);      
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }
    

    Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

     <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
    

    This button update the first line added by bean managed, but the second row remains unchanged.

    Please help how to update the two lines with the same button or something else.

    Concerning

    DML_UPDATE will call only if there is some change data attributes.

    I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

    I assume the update statement should look like:

      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
      {
        PreparedStatement stat = null;
        try
        {
          String sql =
            "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
            "' where VID='" + value1 + "'";
          System.out.println("sql= " + sql);
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • Download a update, I get this message,"you don't have the appropriate permissions. Choose another directory for registration. How to choose another directory for registration?

    Trying to update from Mozilla, I get the error message following, "the file would be not saved because you do not have the appropriate permissions. Choose another directory for registration.

    How to choose another "directory" of record?

    Press Alt + E and then N to bring up your preferences. On the general tab, check the option "always ask me where to save files.

  • How to choose optional updates in Windows Updates?

    How to choose optional updates in Windows Updates? Please send me the steps that is with photos.

    mine is win7 Enterprise

    http://Windows.Microsoft.com/en-us/Windows7/updates-frequently-asked-questions

    What types of Windows updates can install automatically?

    You can set Windows to automatically install important and recommended updates or to install important updates only. Important updates provide significant benefits, such as improved security and reliability. Recommended updates can address non-critical problems and help enhance your computing experience. Optional updates are not downloaded or installed automatically. For more information, seeActivate the update or disable automatic and change how Windows installs or you inform about updates.

    To install drivers and other optional updates

    1. Open Windows Update by clicking on the button start. In the search box, type Update, and then, in the list of results, clickWindows update.

    2. In the left pane, click search for updates, and then wait while Windows searches the latest updates for your computer.

    3. If you see a message telling you that important updates are available, or that optional updates are available, click on a message to view and select the updates to install.

    4. Select the optional updates that you want, click OK, and then updates clickInstall. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    TaurArian [MVP] 2005-2011. The information has been provided * being * with no guarantee or warranty.

  • How to choose not to install a Windows Update?

    There are some updates I don't want.   Essential direct window is one of them.  If Ido choose not to update, the update indicator never goes away.  How can I choose to reject an update and get rid of that flag or opinion?

    human resources management

    Right-click on the update. Hide update. Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • Portal Oracle Gold: how to convert insert them in the update

    In my db goal there is no delete replicated.

    But sometimes, the same key is removed and inserted in the future.

    In this case, how to convert insert them in the update?

    Kind regards

    William

    I have

    If I use this option:

    RESOLVECONFLICT (INSERTROWEXISTS, (BY DEFAULT, OVERWRITE))

    ???

  • How can I insert html into the Actions Panel to format text?

    I am trying to create text using html, so I could format it in html.  I created a text box, it has given an instance name, "Dynamic text" selected and clicked 'display the text in html format.  When I click F9 (go on the Panel shares) to insert my html code, I get the message "current selection cannot have actions applied to it.  Am I missing something?  How can I insert html into the Actions Panel to format text?

    In order to assign html text to a textfield, you must assign your htmlText of a textfield property.  If you must give a name of uinstance to the textfield and then assign the text.  If you named the "tField" textfield, in the scenario that contains the textfield you EF text html as follows...

    tField.htmlText ="

    your text

    ";

    You should watch the TextFields htmlText property in the help documents to determine the limited number of html tags that are supported by Flash.

  • How to insert or update in the data type date

    Hai All

    I have two table T1 and T2 from T1 to T2 I have to move data

    T1 structure code var, varchar of time that I said and T2 intimate outtime, intrinsically, all the introut are the date data type, so I need to pass the data to date the type varchar data


    How to insert or update varchar to date

    Concerning

    Srikkanth.M

    Hello

    SQL> create table tabDate
      2  (dt date);
    
    Table created.
    SQL> declare
      2  v_date varchar2(10):='10-03-2010';
      3  v_time varchar2(10):='0815';
      4   Begin
      5   insert into tabDate values(to_date(v_date||v_time,'dd-mon-yyyy hh24mi'));
      6   end;
      7   /
    declare
    *
    ERROR at line 1:
    ORA-01843: not a valid month
    ORA-06512: at line 5
    
    SQL>  declare
      2   v_date varchar2(10):='10-03-2010';
      3   v_time varchar2(10):='0815';
      4    Begin
      5    insert into tabDate values(to_date(v_date||v_time,'dd-mm-yyyy hh24mi'));
      6  end;
      7  /
    
    PL/SQL procedure successfully completed.
    
    SQL> select to_char(dt,'dd-mm-yyyy hh24mi') from tabDate;
    
    TO_CHAR(DT,'DD-
    ---------------
    
    10-03-2010 0815
    

    Twinkle

  • How to use the Group feature in insert or update

    Hai All

    How to use the Group feature in insert or update statement

    I'm generating attendance so I have a different set of timing example

    0800,1200,1230, 1700 and I need to insert data into the table that contains the intimate value min and max value for

    outtime and othere to inertval time in or out

    Pls tell me with some examples


    For example

    For INSERT

    Insert into T2 (barcode, empcode, respondent, attend_date)
    values (R2.cardn, R2.enpno, min(R2.) PtIMe), R2.pdate);


    Update

    Update dail_att set outtime = MAX (r2.ptime) where empcode = r2.enpno and barcode = r2.cardn and
    attend_date = r2.pdate;


    Here, in the place where I used to have so pls tell how to use

    Thanks and greetings

    Srikkanth.M

    Hi Srikkanth.M

    to insert:

    insert into test (dummy) values ((select max (dummy) to double));

    Update:

    Update test dummy value = (select max (dummy) to double where to test them. XXXXField = double. XXXXField);

Maybe you are looking for

  • Reapply the firmware update?

    I applied the last update of the firmware to my two Iomega NAS EZ devices, but I am sure one of them will as expected somehow, because it performs not only as well as the second. It is very slow in operation and small errors reappear in use. Is it po

  • frequency DAQ USB issue (6211)

    Hello I'm a newbie when it comes to NOR and data acquisition. I bought a NI USB 6211 and connected a resolver with 400 Hz and ai1, ai2 (CSR) (sine and cosine signals). I also have the reference of the power supply connected to ai3 (differential) of s

  • Where can I go to learn more about the scale of pressure readings of different devices to HAVE?

    E.g. I have a sensor Vaisala HMP 60 RHT. How I don't know what scale of pressure readings to get the good HR? I've seen values (for example 20 in the linear range of the Vaisala HMT 100), but I don't know where it comes from or why it is chosen. In w

  • How can I sync my ipod to my computer?

    I tried to get my ipod to sync with my computer, but it won't. It comes, but I can not access my music or whatever it is about that because it syncs automatically or manually and it does not give me the option to do either. When I try to sync to y to

  • Windows 8 why c. not support & Turbo c ++ which run on Windows XP?

    I am a student. And I need to learn and practice C & Turbo C++. I have a portable e-series from sony with Windows 8, but there is no market C & C++.