Insert the statement of the doDML

Hello experts!

I am of the substitution of the doDML of the object of the entity Impl and I want to run a simple sql insert statement.
How can I do this and validate these changes?

Thank you very much!

When you post call doDML method will be called automatically.
You can write the Insert here and you can call commit to manage Bean or AMImpl

Manage in bean

FacesContext fc = FacesContext.getCurrentInstance();
BindingContainer opBindings = (BindingContainer)fc.getApplication().evaluateExpressionGet(fc, "#{bindings}", BindingContainer.class);
OperationBinding operationBinding = opBindings.getOperationBinding("Commit");
operationBinding.execute();

In AMImpl

this.getDBTransaction().commit();

These documents may also be useful for you.
EO - OPERATION DODML
http://andrejusb.blogspot.com/2008/02/complex-insert-in-easy-way.html

Tags: Java

Similar Questions

  • 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();
          }
        }
      }
    
  • Insert the statement Question

    I'm trying to insert a set of values in a table where one of the values necessary for inclusion is identical to the auto-generated primary key. I am not currently insertion of the value for the primary key because it is generated automatically. Given that I'm not insert the value of the primary key, is anyway to set another value inserted on the same primary key value?

    For example:

    insert into ent_config.device (created_dt, created_tz, created_by_seq, modified_dt, modified_tz, modified_by_seq, enterprise_seq, clinicals_organization_seq, facility_id, dept_id, hostname, tty_id, process_num, device_name, device_status, device_type, loc_type, netbios_id, db_name) values (sysdate, 'IS', '106303', sysdate, 'IS', '106303', '5001', '5035', '9', '19', 'phslnx020', 'P12320', ' 2099', 'PC', 'ON_LINE' "cv220") (, 'NUR', * '2736' *, 'ALL');

    The primary key for this table is called device_seq which is generated automatically and must be unique which as you can see from the above insert statement is inserted, and the netbios_id must be set to the same value when inserting.

    No idea how I could go to do this?

    Hello

    Welcome to the forum!

    When you say that device_seq is 'auto generated', do you mean that there is a trigger that provides this value? (I assume you are using a sequence, but it probably does not matter in this issue). See if you can change the trigger. If netbios_id is always the same as device_seq when you INSERT (but can be changed by updates later), then it is very easy. Otherwise, you may need to designate some specail value (as - 9E9) which replaces the trigger with the same value that it used to device_seq.

    Change the trigger is the only good way I can think of that. If you can't touch the existing trigger, you might be able to add a new trigger, but it would be more complicated and less effective.

  • How to insert the value of the variable using select statement - function Oracle

    Hello

    I have a function that inserts the record based on a condition


    INSERT IN the case
    (
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    )(
    SELECT newCaseID,
    caseStatus,
    Closure_Code,
    Closure_Date,
    CASE
    WHERE Case_ID = caseID
    );

    Now, I want the new value casestatus instead of value caseStatus select statement. I have a m_caseStatus variable and I want to use the value of this variable in the select statement above.
    How can I use this.


    Thank you
    INSERT INTO Case
    (
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    )(
    SELECT newCaseID,
    m_caseStatus,  <-- here place your variable
    Closure_Code,
    Closure_Date,
    FROM Case
    WHERE Case_ID = caseID
    );
    

    Nicolas.

  • Insert the statement so that a line taking more than 6 minutes.

    When I tried to insert just one line in a table... it's take more than 6 minutes. No idea why its causing so much time for just insertion of a line.

    Please advice...


    Kind regards
    Yasser.

    YasserRACDBA wrote:
    Charles,

    Yes you are right. Optimizer is set to rule that it is the version of Oracle 8i.

    Problem has been solved... rinse us just sharing pool and insert the statement was finished within 1 second.

    Still confused that how its related to the hot flushes of shared pool... May be due to bad hit ratio.

    Flushing the shared pool causes the instructions shared/updates cached so far in the shared pool to get hard analysis/optimized again. Explanation so the most obvious would be that for some reason, the implementation plan have been changed to the statement you're talking about, although the plan should be quite deterministic, because you're on 8i (no bind variable peeking questions) and using the optimizer basic RULE.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • Insert the select statement result in CLOB

    Hi, I would like to insert the result of a statement select into a CLOB with a trigger.

    Whevner a number is registered my research to trigger how often the number is used in several objects and now my problem I also would like to know the record ID where the number is used.

    SELECT 'ITEXT '.
    OF 'CHECK_INR '.
    WHERE 'USE' > 1

    This select records of results 2 How can I insert the result into a CLOB with my trigger?

    Thanks in advance

    Steven,

    It's really a question better suited for another forum because it is not really associated with ApEx. Also, something tells me that you really want to do an UPDATE not an insert. However, here's a quick example...

    DECLARE
    
       l_orders VARCHAR2(4000);
    
    BEGIN
    
       FOR x IN (
          SELECT *
          FROM my_orders_table
       )
       LOOP
          l_orders := l_orders || ', ' || x.order_data_column;
       END LOOP;
    
       l_orders := l_trim(l_orders, ', ');
    
       UPDATE some_table
       SET some_column = l_orders
       WHERE id = some_id;
    
    END;
    

    That's the key. Use VARCHAR2 unless you need CLOB.

    Kind regards
    Dan

    http://danielmcghan.us
    http://sourceforge.NET/projects/tapigen

  • SQL statement error INSERT The conflicted with the FOREIGN KEY constraint

    I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.

    SQL questions are better posed on Technet.  They are better equipped to manage the

    http://social.technet.Microsoft.com/forums/en-us/categories/

  • Get the message insert the disc of State at startup in windows 7

    Original title: How can I remove the status.msi windows 7

    Whenever I boot, I get the following message: Please insert the 'Status' disk and click OK. The source of use is 1. I use the Task Manager to cancel but it becomes boring. Any help to remove it would be appreciated.

    Try this link:http://www.geekpolice.net/t21995-help-it-keeps-saying-insert-the-status-disk-and-click-ok

    Helped?

  • Insert the statement do not using the MultiSelect values correctly

    I have a set of boxes MultiSelect displayed with in a cfloop. I named the MultiSelect boxes "MultiSelect #ID # with #ID #

    the value of KP for each record retrieved. I do this to make sure that each MultiSelect box has a unique name so that when I

    Insert data by using a query of < cfloop > names of are not in conflict. Here's the HTML for the selectbox.

    < select name = "" MultiSelect #ID # ' several size = "3" > (query #ID 'getNonRoleItemDetails) "
    < cfloop query = "getMultiitems" >
    < option value = "#AddInfoID #" > #Name # < / option > (these two values are taken from the "getMultiItems" query
    < / cfloop >

    Here's the query insert I use on the action page that uses this data.



    < cfloopquery getNonRoleItemDetails >

    < cfquery = name "Datasource =' #application.dbname # of the Insert_Multi_Records" >

    INSERT INTO tblItemDetailUpdates (ItemID, ItemDetailsListID, ItemDetailValue, ActionItemID)

    VALUES (#getNonRoleItemDetails.ItemID #, #getNonRoleItemDetails.ID #, ' #form ["MultiSelect" & ID] #', #ArrayOfIds [Counter] #)

    < / cfquery >
    < / cfloop >



    The problem I have here is that the query works correctly, but it is the insertion of the ID MultiSelect values selected (104, 105,

    (106), rather than the real names of these values (IOC, AP, AR... etc).


    I looked at the source code and each MultiSelect box is named correctly and uniquely. Insert inserts the correct ID

    values, but not the names.

    Sigh too bad I am a fool. Well at least I thought about it.

  • Envy 15 t-j100 Select Edition: the device is not connected to the computer. Please insert the authentication device.

    Hello

    So I'm working on a LT desire that has been upgraded from Windows 8.1 to 10 recently and it is this message on the login screen "the device is not connected to the computer. Insert the authentication device. We can't identify what it means or what needs to be done to clear the screen. The user States that the fingerprints of impression of BIO sensor doesn't seem to work either. I looked in the Device Manager, and I see a Synaptics PS sensors (WBF) listed here and is properly installed. I even updated the driver of sensor ep on the support site of the desire, and we still see on the login screen.

    Y at - it no information or help to clear this message?

    We also note that the number on the keypad lock seems to be disabled during startup of windows 10 upwards. Before on windows 8.1 has been activated. Is there any setting to 10 to keep the active number lock.

    The user says if 10 can be made to work well, then we can go back to 7 or 8.

    Please notify.

    Thank you for your time.

    Seems to have been resolved in re - install the software HP Simple pass then go and reconfigure the settings. Message no longer appears on 10. User LT installed with 7 however. Best decision.

  • GPBase Service2 is missing insert the disc

    Original title: Cody - Support Engineer. ___

    Cody - Support Engineer

    Cody, I'm brand new to this and this is my first request for assistance.  I'm looking for an answer to the question you answered on 10 June 2010, a person having problems with my HP printer.  I have the same request to disk GPBaseService2.

    Here is my response from HP: I've almost worn out my printer installation disc in uninstalling and reinstalling.

    Hello Robert,.

    Thank you for contacting HP Total Care.

    After reading your email, I understand you get error message "GPBase".
    Service2 is missing to insert the disc.

    Robert, I wish I could help with this issue however, I wish to inform you that you receive the error message isn't an error printer. It is a Windows error and you need to connect to Microsoft for repair.

    If you need help, please reply to this message and we will be happy to help you further.

    For more information on keep your HP and Compaq products up and running, please visit our Web site
    to:
    http://www.HP.com/go/TotalCare

    Sincerely,

    Vick
    HP Total Care

    16/08/2010

    Cody, can you help me to get rid of 'the component you are trying to use is on a CD-ROM or another drive that is not' available with "insert disk"GPBaseService2", and then click OK.

    HP said guys must bail out their release they say that they are not of it.

    Please reply,

    robertdpeterson

    Hello
     
     
     
    1. When you encounter this error message?
    2. this message of random error or you get while launching or using a particular application?
    3. What is the number of the HP printer model?
     
    Method 1.
    I recommend you to perform a clean boot to find the application with which it is associated. See the article below for instructions on how to start your computer in a clean boot state.
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: When the diagnosis is complete do not forget to reset the computer to a normal startup. Follow step 7 in the above article.

    Method 2.
    Similar problem is also discussed on the HP forums, where a user has solved this problem by uninstalling and reinstalling the printer software.

     
    I hope this helps.

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Insert the object into the table

    Hi all

    I would insert my type of object in a table without specifying the name of the variable.

    That's my bad example:

    create or replace type MY_TYPE_OBJ as object 
    (
      val1 number,
      val2 number,
      val3 number
    );
    /
    
    CREATE TABLE MY_TABLE of MY_TYPE_OBJ;
    /
    
    declare 
        myType   MY_TYPE_OBJ;
    begin
    
      myType := new MY_TYPE_OBJ(1, 2, 3);
    
      insert into MY_TABLE values (myType.val1, myType.val2, myType.val3);
      
    end;
    /
    
    

    As you can see, on my last procedure, I had to use the insert into statement with val1, val2, val3 name filed.

    Is there a quicker way to insert an object into a table? In the production environment of the object type that almost 100 filed is not so friendly to write each one by one.

    Thank you

    Federico

    Example:

    SQL> create or replace type TFoo as object(
      2          attr1   integer,
      3          attr2   varchar2(10),
      4          attr3   date
      5  );
      6  /
    
    Type created.
    
    SQL>
    SQL> create table footab of TFoo(
      2          attr1 primary key,
      3          attr2 not null
      4  ) organization index
      5  /
    
    Table created.
    
    SQL>
    SQL> declare
      2          foo     TFoo;
      3  begin
      4          foo := new TFoo( 1, 'test1', trunc(sysdate) );
      5          insert into footab values foo;
      6  end;
      7  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> select * from footab;
    
         ATTR1 ATTR2      ATTR3
    ---------- ---------- -------------------
             1 test1      2014/08/27 00:00:00
    
    SQL>
    

    I agree though - be careful with tables of objects and now their technical implementation and advantages and disadvantages.

  • Insert the ROWNUM in a column of data type of NUMBER table

    Hello

    I have a table that has a column named "rank" of the NUMBER data type. Basically, I want to make an analysis of top-n and insert the ROWNUM with other columns in the table.

    Definition of table1:

    CREATE TABLE

    (

    col1 VARCHAR2 (10),

    Col2 NUMBER,

    NUMBER of col3,

    rank NUMBER

    );

    INSERT INTO table1

    SELECT col1, col2, col3, rownum

    DE)

    SELECT col1, col2, col3

    FROM table2

    ORDER BY DESC of col3

    )

    WHERE rownum < = 5;

    I get an error ORA-01722: invalid number. I think the mistake is virtual ROWNUM is not data type of NUMBER, so I tried to cast as CAST (ROWNUM AS NUMBER), but it does not work, same error. Can can you please shed some light on how to convert a ROWNUM number or if the issue is something else.

    you're right, your example worked. It is an example of table I just created just to illustrate the problem, but my real table was always showing the same problem. Weird, isn't? However when I added the column names after that insert the question but statement I resolved. Adding code

    INSERT INTO TABLE1

    (col1, col2, col3, rank) - added

    SELECT col1, col2, col3, rownum

    DE)

    SELECT col1, col2, col3

    FROM table2

    ORDER BY DESC of col3

    )

    WHERE rownum<=>

    So that means ROWNUM returns number; and another confusion: why the inclusion of the column has solved my problem when it is not necessary for your example. in any case thank you.

  • Insert the problem using a SELECT table with an index by TRUNC function

    I came across this problem when you try to insert a select query, select returns the correct results, but when you try to insert the results into a table, the results are different. I found a work around by forcing a selection order, but surely this is a bug in Oracle as how the value of select statements may differ from the insert?

    Platform: Windows Server 2008 R2
    11.2.3 Oracle Enterprise Edition
    (I've not tried to reproduce this on other versions)

    Here are the scripts to create the two tables and the data source:
    CREATE TABLE source_data
    (
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    );
    
    CREATE INDEX IN_SOURCE_DATA ON SOURCE_DATA (TRUNC(count_date, 'MM'));
    
    INSERT INTO source_data VALUES (1, TO_DATE('20120101', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120102', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120103', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120201', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120202', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120203', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120301', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120302', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120303', 'YYYYMMDD'));
    
    CREATE TABLE result_data
    (
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    );
    Now, execute the select statement:
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')
    You should get the following:
    1     2012/02/01
    1     2012/03/01
    1     2012/01/01
    Now insert in the table of results:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM');
    Select the table, and you get:
    1     2012/03/01
    1     2012/03/01
    1     2012/03/01
    The most recent month is repeated for each line.

    Truncate your table and insert the following statement and results should now be correct:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')
    ORDER BY 1, 2;
    If someone has encountered this problem before, could you please let me know, I don't see what I make a mistake because the selection results are correct, they should not be different from what is being inserted.

    Published by: user11285442 on May 13, 2013 05:16

    Published by: user11285442 on May 13, 2013 06:15

    Most likely a bug in 11.2.0.3. I can reproduce on Red Hat Linux and AIX.

    You can perform a search on MOS to see if this is a known bug (very likely), if not then you have a pretty simple test box to open a SR with.

    John

  • Insert the record type

    Hi all

    I created a table with two columns method. I am assigned two values to variable recordtype.
    When inserting the record in the table, a compiler error is to be there.
    Create table emp_info(empno number(5),ename varchar2(30));
    
    DECLARE
    
    l_rec emp_info%rowtype;
    
    BEGIN
    
    l_rec.empno := 101;
    l_rec.ename := 'KING';
    
    insert into emp_info(empno,ename)
    values(l_rec);
    
    commit;
    
    END;
    ERROR on line 11:
    ORA-06550: line 10, column 35:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 10, column 1:
    PL/SQL: SQL statement ignored


    Can I insert with output Recordtype variables indicating the column names. Can someone help me?

    Do not list of columns. Do not put brackets in the record variable:

    SQL> DECLARE
      2      l_rec emp_info%rowtype;
      3  BEGIN
      4      l_rec.empno := 101;
      5      l_rec.ename := 'KING';
      6      insert
      7        into emp_info
      8        values l_rec;
      9       commit;
     10  END;
     11  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

Maybe you are looking for