title: Inserting/Updating Rows to DB table where Rows result from VO [Backed by EO] based on Union Query
body: <p>Jdev Version : 11.1.1.7</p>
  
  <p>I have created a Department VO based Department EO with the following query :</p>
  
  <pre><code>SELECT DeptEO.DEPARTMENT_ID,
     DeptEO.DEPARTMENT_NAME,
     DeptEO.MANAGER_ID,
     DeptEO.LOCATION_ID,
     DeptEO.ACTIVE
  FROM DEPARTMENTS DeptEO where DeptEO.DEPARTMENT_ID &gt; 250
  UNION
  SELECT 280 , 'Advertising',200,1700,'Y' from Dual
  </code></pre>
  
  <p>For the simplicity , I have used a sample statement from dual table , in real scenario , the query after UNION clause will populate from a table.
  After running the query ,I get the result that is desired on the UI .</p>
  
  <p>Now my requirement is to insert this newly created  row with DEPARTMENT_ID as 280 , into DB table DEPARTMENTS.
  While committing , ADF throws error as " oracle.jbo.RowAlreadyDeletedException: JBO-29114 " which is correct as the this row is missing from DB table , so when it goes for taking a lock on the row for update , it doesn't find anything .</p>
  
  <p>Is there any way that i can instruct ADF to consider this row for Insert rather than update .
  We also tried to populate the data of this row into a new row instance created from RowSetIterator , and afterwards remove the culprit row by calling removeFromCollection() and then inserting the duplicated row , but still no luck .</p>
  
  <p>Other approaches that we are thinking of are :</p>
  
  <p>1- Create another VO/EO and insert values in table through them .
  2- Create a DB View for this query and trigger on this view , so when ever an update operation comes , we do our logic in trigger i.e. decide whether to update or insert the data.</p>
  
  <p>Can you please guide what should be done in such scenario .</p>
  
  <p>Regards,</p>
  
  <p>Siddharth</p>
  
  <p>Edit : Code for Inserting Row (What I was trying but it's not working)</p>
  
  <pre><code>    RowSetIterator rsi=iterator.getRowSetIterator();
     Row editableRow= rsi.createRow();
  
      while(rsi.hasNext()){
          Row r =rsi.next();
  
          if((""+r.getAttribute("DepartmentId")).toString().equals("280") ){
              System.err.println("? Equality row found!!!");
              editableRow.setAttribute("DepartmentId", r.getAttribute("DepartmentId"));
              editableRow.setAttribute("DepartmentName", r.getAttribute("DepartmentName"));
              editableRow.setAttribute("ManagerId", r.getAttribute("ManagerId"));
              editableRow.setAttribute("LocationId", r.getAttribute("LocationId"));
              editableRow.setAttribute("Active", r.getAttribute("Active"));
  
              rsi.removeCurrentRowFromCollection();
          }
      }
  
      if(editableRow !=null){
          System.err.println("? Row value after removal : "+editableRow.getAttribute("DepartmentName"));
  
          rsi.insertRow(editableRow);
          operBindingCommit.execute();
      }
  </code></pre>