Use Preparedstatement to delete several rows from database

Hello everyone,
I am trying to delete multiple rows from database at one time using Preparedstatement.
It works well when I tried in SQL directly,the sql query is as follows:
delete from planners_offices where planner ='somename' and office in ( 'officeone', 'officetwo', 'officethree')
I want to delete those 3 rows at one time.
But when I am using preparedstatement to implement this function, it does not work. It did not throw any exception, but just does not work for me, the updated rows value always returns "0".
Here is my simplified code:
PreparedStatement ps = null;
sqlStr = " delete from PLANNERS_OFFICES where planner = ? and office in (?) "
Connection con = this.getConnection(dbname);
try
//set the sql statement into the preparedstatement
ps = con.prepareStatement(sqlStr);
ps.setString(1,"somename");
ps.setString(2,"'officeone','officetwo','officethree'");
int rowsUpdated =ps.executeUpdate();
System.out.println(rowsUpdated);
//catch exception
catch (SQLException e)
System.out.println("SQL Error: " + sqlStr);
e.printStackTrace();
catch (Exception e) {
e.printStackTrace();
} finally {
this.releaseConnection(dbname, con);
try{
ps.close();
}catch (SQLException e){
e.printStackTrace();
rowsUpdated always give me "0".
I tried only delete one record at one time, "ps.setString(2, "officeone");", it works fine.
I am guessing the second value I want to bind to the preparedstatement is not right, I tried several formats of that string, it does not work either.
Can anyone give me a clue?
Thanks in advance !
Rachel

the setString function in a preparedStatement doesn't just do a replace with the question mark. It is doing some internal mumbojumbo(technical term) to assign your variable to the ?.
If you are looking to do your statement, then you will need to put in the correct of # of question marks as you need for the in clause.
delete from PLANNERS_OFFICES WHERE PLANNER = ? and office in (?,?,?)
If you need to allow for one or more parameters in your in clause, then you will need to build your SQL dynamically before creating your prepared statement.
ArrayList listOfOfficesToDelete ;
StringBuffer buffer = new StringBuffer("DELETE FROM PLANNERS_OFFICES WHERE PLANNER = ? AND OFFICE IN (");
for(int i = 0; i < listOfOfficesToDelete.size(); i++ )
   if( i != 0 )
       buffer.append(",");
   buffer.append("?");
buffer.append(")");
cursor = conn.prepareStatement( buffer.toString() );
cursor.setString(1, plannerObj);
for(int i = 0; i < listOfOfficesToDelete().size(); i++ )
    cursor.setString(i+1, listOfOfficesToDelete.get(i) );
cursor.executeUpdate() ;

Similar Messages

  • HOW TO DELETE THE ROW FROM DATABASE

    hI,
    Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.
    thanks
    naveen
    [email protected]
    <%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,java.util.Vector,java.util.StringTokenizer" %>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Item Details</title>
    <script>
    function submitPage()
    document.details.action = "itemdetails.jsp" ;
    document.details.submit();
    </script>
    </head>
    <body>
    <form name="details" action="itemdetails.jsp" method="post">
    <%
    ConnectionPool pool;
    Connection con = null;
    Statement st;
    ResultSet rs =null;
    %>
    <table border="0" cellpadding="0" cellspacing="0" width="328">
    <tr>
    <td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
    <input type="submit" value="search" name="search" ></td>
    </tr>
    <tr>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item Code</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item No</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Amount </b></font></td>
    <td width="80" bgcolor="#000099"> </td>
    </tr>
    <%
    pool= new ConnectionPool();
    Utils utils = new Utils();
    double total =0.00;
    String search =utils.returnString(request.getParameter("search"));
    if(search.equals("search"))
    try
    String ref_no =utils.returnString(request.getParameter("txt_refno"));
    String strSQL="select * from ref_table where refno='" + ref_no + "' ";
    con = pool.getConnection();
    st=con.createStatement();
    rs = st.executeQuery(strSQL);
    while(rs.next())
    String itemcode=rs.getString(2);
    int item_no=rs.getInt(3);
    double amount= rs.getDouble(4);
    total= total + amount;
    %>
    <tr>
    <td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
    <td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
    <td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
    <td width="80"><a href="delete</td>
    </tr>
    <%
    }catch(Exception e){}
    finally {
    if (con != null) pool.returnConnection(con);
    %>
    <tr>
    <td width="323" colspan="4">
    <p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
    </tr>
    <tr>
    <td width="323" colspan="4">                   
    <input type="button" value="save" name="save"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    You mean when you click on the hyperlink you want that row to disappear from the page, but not delete the row from the database until a commit/submit button is pressed?
    Personally, I think I'd prefer that you have a delete checkbox next to every row and NOT remove them from the display if I was a user. You give your users a chance to change their mind about their choice, and when they're done they can see exactly which rows will be deleted before they commit.
    You know your problem, of course, so you might have a good reason for designing it this way. But I'd prefer not removing them from the display. JMO - MOD

  • How to delete a row from database table in facade client

    Hi all,
    I followed the tutorial in creating a persistence entity from database table, then a session facade. Then I followed the tutorial to create a sample client to test the model. In the session facade, I could use persistEntity method to insert a record to the database. I am just thinking of an extension to the tutorial, i.e., being able to delete the record too. So I created a new method removeEntity in the session facade
    public void removeEntity(Object entity) {
    entity=em.merge(entity);
    em.remove(entity);
    em.flush();
    and called it in the sample client. It was executed without any error, but the record in the table still exists.
    I tried to look around for a solution, but I did not find one. Would anybody here please help out? Many thanks in advance!

    Hi Frank,
    I tried the code snippet, but I got the following exception when executing this code:
    javax.ejb.EJBException: EJB Exception: ; nested exception is:
         java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.; nested exception is: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
    java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:121)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
         at $Proxy141.getTransaction(Unknown Source)
         at model.SessionEJBBean.removeEntity(SessionEJBBean.java:60)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:55)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy143.removeEntity(Unknown Source)
         at model.SessionEJB_qxt9um_SessionEJBImpl.removeEntity(SessionEJB_qxt9um_SessionEJBImpl.java:142)
         at model.SessionEJB_qxt9um_SessionEJBImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    javax.ejb.EJBException: EJB Exception: ; nested exception is:
         java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.; nested exception is: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:109)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:91)
         at $Proxy0.removeEntity(Unknown Source)
         at model.SessionEJBClient.main(SessionEJBClient.java:71)
    Caused by: java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
         at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:121)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
         at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
         at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
         at $Proxy141.getTransaction(Unknown Source)
         at model.SessionEJBBean.removeEntity(SessionEJBBean.java:60)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:55)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy143.removeEntity(Unknown Source)
         at model.SessionEJB_qxt9um_SessionEJBImpl.removeEntity(SessionEJB_qxt9um_SessionEJBImpl.java:142)
         at model.SessionEJB_qxt9um_SessionEJBImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Process exited with exit code 0.

  • Deleting several rows from a query

    I have a query with several rows that have a field with the
    string "2 by 4" that I would like to delete. There are other rows
    where this same field is "2 by 2" and I don't want to delete those
    rows.
    What's the syntax? Can I use structdelete? Or is this
    data-structure an array?

    Use the where clause of your sql to select only the records
    you want. If you actually need all the records you are getting now,
    and you also want a subset of those records, use query of queries
    to get your subset.

  • Problem in deleting row from database in table component

    Hi,
    I have a table component that its content change by diffrent links.
    in this table i have a hyperlink in each row to deleting that row from dataBase.
    so i must get the current row .
    i do it like this:
    define a rowset in the page that have a delete query :
    delete from response where responseID=?
    in action of delete hyperlink ,i have:
    Integer responseId=(Integer)responseDataProvider.
    getValue("#{currentRow.value['responseID']}") ;
    getSessionBean1().getResponseRowSet().setObject(1,responseId);
    getSessionBean1().getResponseRowSet().execute();
    but in first line occure a exception:
    illigalArgument #{currentRow.value['responseID']}
    thanks.

    by using data table
    first you should get current record (row that recived action)
    then delete it by using data provider.
    I do not think that you could execute delete statement using rowSets because they just can provide Select statements.
    btw , following code will retrive clicked row from data table and
    delete that row
    try {
    RowKey rk = getTableRowGroup1().getRowKey();
    if (rk != null) {
    testDataProvider.removeRow(rk);
    testDataProvider.commitChanges();
    } catch (Exception ex) {
    log("ErrorDescription", ex);
    error(ex.getMessage());
    hth
    masoud

  • Deleting a row from a table using jsp

    Given a table in a jsp, can an user click on a row of that table and retrieve the information so that the program can delete a record from a database table?
    most of the tables that I have seen are static, the user cannot interact with them(specially when the user wants to delete several records from a database table).
    Can anyone suggests a good book or way of deleting a row from table using jsp.

    eg use a column in the table that has a radio button or check box,
    on submit, get all the rows that are checked, using the row as an index into your db store, get the key and use the key to issue the sql delete command.

  • Deleting a row from a database...

    Here is the method I am calling to delete a row from a database. I keep getting this error, but I am not sure why.
    Error: "Too few parameters. Expected 1."
    //To delete a row
      public void removeRow(String x, String y) {
       try {
       Statement stmt = con.createStatement();
       //delete row with same x and y
    //first is a string and second is a number
       String query = "DELETE * FROM table WHERE first = '" +x+ "' AND " +
       "second = " +Integer.parseInt(y);
       int result = stmt.executeUpdate(query); //runs delete query, ERROR HERE *************
       System.out.println("Test"); //debug statement, never gets here
       //deletion confirmation message
       JOptionPane.showMessageDialog(null, "Row deleted",
       "Delete Reservation", JOptionPane.INFORMATION_MESSAGE);
          catch (Exception e) { System.out.println(e); }

    Additionally, in the future you might want to use:
    catch(SQLException sqlx) {
      System.out.println( sqlx.getSQLState()
                                       +"\t"+sqlx.getMessage()
                                       +"\t"+sqlx.getErrorCode() );... It'll help with diagnostics.
    &#9786;Bill

  • Best practice for deleting multiple rows from a table , using creator

    Hi
    Thank you for reading my post.
    what is best practive for deleting multiple rows from a table using rowSet ?
    for example how i can execute something like
    delete from table1 where field1= ? and field2 =?
    Thank you

    Hi,
    Please go through the AppModel application which is available at: http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    The OnePage Table Based example shows exactly how to use deleting multiple rows from a datatable...
    Hope this helps.
    Thanks,
    RK.

  • Delete a row from a data object using an AQ-driven EMS

    Hello, technetwork.
    I need to show the contents of a table that changes frequently (inserts, updates and deletes) at ORDBMS 10g in my BAM dashboard.
    What i have done is:
    - Create two different queue tables, queues.
    - Create two triggers: one for "AFTER insert or UPDATE" and the other for "BEFORE DELETE".
    - Create two EMS, one configured to Upsert operations and the other to Delete.
    - The Upsert EMS works, but the Delete EMS does not.
    - Both EMS Metrics say that they work fine and commit the messages i send to the ADC.
    - Testing showed records are populated and updated in the ADC but never deleted.
    There is a detailed user case for "Creating an EMS Against Oracle Streams AQ JMS Provider" in the Fusion Midleware Developer's Guide for SOA Suite, but it deals only with Upserts. I am using the last versions of SOA suite and Weblogic. The official support has no information either.
    I hope writing a web service client isn't the only way to delete a row from a data object. Am i missing something? Any help will be much appreciated.
    My EMS config:
    Initial Context Factory: weblogic.jndi.WLInitialContextFactory.
    JNDI Service Provider URL: t3://<spam>:80.
    Topic/Queue Connection Factory Name: jms/BAMAQTopicCF.
    Topic/Queue Name: jms/ProdGlobalBAMD_flx.
    JNDI Username: .
    JNDI Password: .
    JMS Message Type: TextMessage.
    Durable Subscriber Name (Optional): BAM_ProdGlobalBAMD.
    Message Selector (Optional): .
    Data Object Name: /bam/ProdGlobalBAM_flx.
    Operation: Delete.
    Batching: No.
    Transaction: No.
    Start when BAM Server starts: No.
    JMS Username (Optional): .
    JMS Password (Optional): .
    XML Formatting
    Pre-Processing
    Message Specification
    Message Element Name: row
    Column Value
    Element Tag
    Attribute
    Source to Data Object Field Mapping
    Key Tag name Data Object Field
    . BARCODE. BarCode.
    Added my EMS config

    Ram_J2EE_JSF wrote:
    How to accomplish this using JavaScript?Using Javascript? Well, you know, Javascript runs at the client side and intercepts on the HTML DOM tree only. The JSF code is completely irrelevant. Open your JSF page in your favourite webbrowser and view the generated HTML source. Finally just base your Javascript function on it.

  • Deleting a row from a Parent VO gives NullPointerException

    I am using JDev 11.1.1.2.0
    Deleting a row from a Parent VO gives NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
    Here is my implementation:
    There are two Entity Objects(Named "Parent" and "Child").
    Both EO are NOT based on a database table. (These are populated from a method in the AM, the method calls a database API that returns an nested array and this array is used to populate the Parent and Child entities)
    All attributes in these entity objects are Non-persistent.
    The View Object "ParentEv" is based on "Parent" EO
    The View Object "ChildEv" is based on "Child" EO
    The View Objects "ParentEv" and "ChildEv" are linked by a view link.
    The Entities "Parent" and"Child" are linked by Entity Association ( as "Composition Association" with "Implement Cascade Delete" checked.)
    I am programatically deleting and populating the View Objects ParentEv and ChildEv from a method in the AM.
    The first time I execute the method in BC Tester, it works fine.
    The second time I execute the method it works fine.
    But on third execution, it gives the below error which seems to be NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
    I am able to reproduce this in a test case scenario. It always works the first 2 times and fails when the method to delete and populate the VOs is executed a 3rd time.
    If we base the "Parent" and "Child" entities on some dummy database views, it works fine, the problem only occurs when the Entities are NOT based on any table.
    Can someone advise on what could be causing this issue?
    Thanks,
    Mitesh.

    Here's the method that I use in my test case to populate the VOs.
       * This method populates the VOs ParentEv and ChildEv.
       * These VOs are based on EOs Paren and Child, respectively.
       * Before populating the VOs I am deleting any existing rows.
       * The first two times this method is executed, it works fine.
       * The third time this method executes it gives a nullpointerexception raised from
       * oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
      public void populateMethod(){
        int rowCount = getParentEv().getRowCount();   
        for (int i = 0; i < rowCount; i++) {
             Row row = getParentEv().last();
             if(row!=null)
               row.remove();
        rowCount = getChildEv().getRowCount();
        for (int i = 0; i < rowCount; i++) {
         Row row = getChildEv().last();
         if(row!=null)
           row.remove();
        int k = 0;
        for (int i = 1; i < 5; i++) {   
          ParentEvRowImpl parentEvRow = (ParentEvRowImpl)getParentEv().createRow();
          parentEvRow.setParentPk("Parent " + i);
          parentEvRow.setParentDesc("Parent Desc " + i);
          getParentEv().insertRow(parentEvRow);   
          for (int j = 1; j < 5; j++) {   
         k++;
         ChildEvRowImpl childEvRow = (ChildEvRowImpl)getChildEv().createRow();
         childEvRow.setChildPk("Child " + k);
         childEvRow.setChildDesc("Child Desc " + k);
         getChildEv().insertRow(childEvRow);   
      }==============================================================================
    Here is the Parent.xml for the Parent EO:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
    <!---->
    <Entity
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="Parent"
      Version="11.1.1.55.36"
      AliasName="Parent"
      BindingStyle="OracleName"
      UseGlueCode="false"
      RowClass="oracle.jbo.server.EntityImpl"
      DefClass="oracle.jbo.server.EntityDefImpl"
      CollClass="oracle.jbo.server.EntityCache">
      <DesignTime>
        <AttrArray Name="_publishEvents"/>
      </DesignTime>
      <Attribute
        Name="ParentPk"
        IsQueriable="false"
        IsPersistent="false"
        ColumnName="PARENTPK"
        SQLType="VARCHAR"
        Type="java.lang.String"
        ColumnType="$none$"
        PrimaryKey="true"/>
      <Attribute
        Name="ParentDesc"
        IsQueriable="false"
        IsPersistent="false"
        ColumnName="$none$"
        SQLType="VARCHAR"
        Type="java.lang.String"
        ColumnType="$none$"/>
      <AccessorAttribute
        Name="Child"
        Association="model.eo.ea.ChildParentAssoc"
        AssociationEnd="model.eo.ea.ChildParentAssoc.Child"
        AssociationOtherEnd="model.eo.ea.ChildParentAssoc.Parent"
        Type="oracle.jbo.RowIterator"
        IsUpdateable="false"/>
    </Entity>==============================================================================
    Here is the Child.xml for the Child EO:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
    <!---->
    <Entity
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="Child"
      Version="11.1.1.55.36"
      AliasName="Child"
      BindingStyle="OracleName"
      UseGlueCode="false">
      <DesignTime>
        <AttrArray Name="_publishEvents"/>
      </DesignTime>
      <Attribute
        Name="ChildPk"
        IsUpdateable="while_insert"
        IsQueriable="false"
        IsPersistent="false"
        IsNotNull="true"
        ColumnName="CHILDPK"
        SQLType="VARCHAR"
        Type="java.lang.String"
        ColumnType="$none$"
        PrimaryKey="true"/>
      <Attribute
        Name="ChildDesc"
        IsQueriable="false"
        IsPersistent="false"
        ColumnName="$none$"
        SQLType="VARCHAR"
        Type="java.lang.String"
        ColumnType="$none$"/>
      <Attribute
        Name="ParentPk"
        IsQueriable="false"
        IsPersistent="false"
        IsNotNull="true"
        ColumnName="$none$"
        SQLType="VARCHAR"
        Type="java.lang.String"
        ColumnType="$none$"/>
    </Entity>==============================================================================
    Here is the ChildParentAssoc.xml for the Association between Parent and Child EOs:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE Association SYSTEM "jbo_03_01.dtd">
    <!---->
    <Association
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="ChildParentAssoc"
      Version="11.1.1.55.36">
      <DesignTime>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <AssociationEnd
        Name="Parent"
        Cardinality="1"
        Source="true"
        Owner="model.eo.Parent"
        DeleteContainee="true"
        LockLevel="NONE"
        ExposedAccessor="false">
        <DesignTime>
          <Attr Name="_aggregation" Value="0"/>
          <Attr Name="_finderName" Value="Parent"/>
          <Attr Name="_isUpdateable" Value="true"/>
          <Attr Name="_minCardinality" Value="1"/>
        </DesignTime>
        <AttrArray Name="Attributes">
          <Item Value="model.eo.Parent.ParentPk"/>
        </AttrArray>
      </AssociationEnd>
      <AssociationEnd
        Name="Child"
        Cardinality="-1"
        Owner="model.eo.Child"
        HasOwner="true">
        <DesignTime>
          <Attr Name="_aggregation" Value="0"/>
          <Attr Name="_finderName" Value="Child"/>
          <Attr Name="_isUpdateable" Value="true"/>
        </DesignTime>
        <AttrArray Name="Attributes">
          <Item Value="model.eo.Child.ParentPk"/>
        </AttrArray>
      </AssociationEnd>
    </Association>==============================================================================
    Here is the ParentEv.xml for the ParentEv VO:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="ParentEv"
      Version="11.1.1.55.36"
      BindingStyle="OracleName"
      CustomQuery="true"
      RowClass="model.vo.ev.ParentEvRowImpl"
      ComponentClass="model.vo.ev.ParentEvImpl"
      PageIterMode="Full"
      UseGlueCode="false">
      <DesignTime>
        <Attr Name="_codeGenFlag2" Value="Access|Coll"/>
        <Attr Name="_isExpertMode" Value="true"/>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <EntityUsage
        Name="Parent"
        Entity="model.eo.Parent"/>
      <ViewAttribute
        Name="ParentDesc"
        IsSelected="false"
        IsQueriable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="255"
        EntityAttrName="ParentDesc"
        EntityUsage="Parent"
        AliasName="PARENTDESC"/>
      <ViewAttribute
        Name="ParentPk"
        IsQueriable="false"
        IsPersistent="false"
        PrecisionRule="true"
        EntityAttrName="ParentPk"
        EntityUsage="Parent"/>
      <ViewLinkAccessor
        Name="ChildEv"
        ViewLink="model.vo.vl.ChildEvParentEvVl"
        Type="oracle.jbo.RowIterator"
        IsUpdateable="false"/>
    </ViewObject>==============================================================================
    Here is the ChildEv.xml for the ChildEv VO:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="ChildEv"
      Version="11.1.1.55.36"
      BindingStyle="OracleName"
      CustomQuery="true"
      RowClass="model.vo.ev.ChildEvRowImpl"
      ComponentClass="model.vo.ev.ChildEvImpl"
      PageIterMode="Full"
      UseGlueCode="false">
      <DesignTime>
        <Attr Name="_codeGenFlag2" Value="Access|Coll"/>
        <Attr Name="_isExpertMode" Value="true"/>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <EntityUsage
        Name="Child"
        Entity="model.eo.Child"/>
      <ViewAttribute
        Name="ChildDesc"
        IsSelected="false"
        IsQueriable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="255"
        EntityAttrName="ChildDesc"
        EntityUsage="Child"
        AliasName="CHILDDESC"/>
      <ViewAttribute
        Name="ChildPk"
        IsUpdateable="while_insert"
        IsQueriable="false"
        IsPersistent="false"
        IsNotNull="true"
        PrecisionRule="true"
        EntityAttrName="ChildPk"
        EntityUsage="Child"/>
      <ViewAttribute
        Name="ParentPk"
        IsQueriable="false"
        IsPersistent="false"
        IsNotNull="true"
        PrecisionRule="true"
        EntityAttrName="ParentPk"
        EntityUsage="Child"/>
    </ViewObject>==============================================================================
    Here is the ChildEvParentEvVl.xml for the view link between ParentEv and ChildEv VOs:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE ViewLink SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewLink
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="ChildEvParentEvVl"
      Version="11.1.1.55.36">
      <DesignTime>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <ViewLinkDefEnd
        Name="ParentEv"
        Cardinality="1"
        Owner="model.vo.ev.ParentEv"
        Source="true">
        <DesignTime>
          <Attr Name="_finderName" Value="ParentEv"/>
          <Attr Name="_isUpdateable" Value="true"/>
        </DesignTime>
        <AttrArray Name="Attributes">
          <Item Value="model.vo.ev.ParentEv.ParentPk"/>
        </AttrArray>
      </ViewLinkDefEnd>
      <ViewLinkDefEnd
        Name="ChildEv"
        Cardinality="-1"
        Owner="model.vo.ev.ChildEv">
        <DesignTime>
          <Attr Name="_finderName" Value="ChildEv"/>
          <Attr Name="_isUpdateable" Value="true"/>
        </DesignTime>
        <AttrArray Name="Attributes">
          <Item Value="model.vo.ev.ChildEv.ParentPk"/>
        </AttrArray>
      </ViewLinkDefEnd>
    </ViewLink>

  • Deleting Multiple Rows From Multiple Tables As an APEX Process

    Hi There,
    I'm interesting in hearing best practice approaches for deleting multiple rows from multiple tables from a single button click in an APEX application. I'm using 3.0.1.008
    On my APEX page I have a Select list displaying all the Payments made and a user can view individual payments by selecting a Payment from the Select List (individual items are displayed below using Text Field (Disabled, saves state) items with a source of Database Column).
    A Payment is to be deleted by selecting a custom image (Delete Payments Button) displayed in a Vertical Images List on the same page. The Target is set as the same page and I gave the Request a name of DELETEPAY.
    What I tried to implement was creating a Conditional Process On Submit - After Computations and Validations that has a source of a PL/SQL anonymous block as follows:
    BEGIN
    UPDATE tblDebitNotes d
    SET d.Paid = 0
    WHERE 1=1
    AND d.DebitNoteID = :P7_DEBITNOTEID;
    INSERT INTO tblDeletedPayments
    ( PaymentID,
    DebitNoteID,
    Amount,
    Date_A,
    SupplierRef,
    Description
    VALUES
    ( :P7_PAYMENTID,
    :P7_DEBITNOTEID,
    :P7_PAID,
    SYSDATE,
    :P7_SUPPLIERREF,
    :P7_DESCRIPTION
    DELETE FROM tblPayments
    WHERE 1=1
    AND PaymentID = :P7_PAYMENTID;
    END;
    The Condition Type used was Request = Expression 1 where Expression 1 had a value of DELETEPAY
    However this process is not doing anything!! Any insights greatly appreciated.
    Many thanks,
    Gary.

    ...the "button" is using a page level Target,...
    I'm not sure what that means. If the target is specified in the definition of a list item, then clicking on the image will simply redirect to that URL. You must cause the page to be submitted instead, perhaps by making the URL a reference to the javaScript doSubmit function that is part of the standard library shipped with Application Express. Take a look at a Standard Tab on a sample application and see how it submits the page using doSubmit() and emulate that.
    Scott

  • How to delete multiple rows from ADF table

    How to delete multiple rows from ADF table

    Hi,
    best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
    Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
    Frank

  • Deleting A Row From Datagrid

    Hai
        I have pasted the mxml below, because i am unable to attach the mxml, pl copy this below file into flex and run the application.
      1. Run the application.
      2. Enter values in the textbox and click add, values will be added to the datagrid.
      3. now click AND or OR and then change the values in the second and thrid combobox and again click add.
      4.Like wise change the combobox values and add five rows to the datagrid.
    5.now if u delete the last row u can see the curent last row in the combobox, so that the AND or Or can be added to it
    6. now if u delete a row in between, the deleted row's value oly maintains in the combobox,so i am unable to add AND or Or to the grid
      7.I need the last row data in the datagrid to be in the second and third combobox, which ever row is deleted.
    Can anyone help me....
    Thanks in advance.
    This is the mxml for sample
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
    <![CDATA[
      // ActionScript file
    import mx.rpc.events.FaultEvent;
    import mx.controls.Alert;
            import mx.managers.CursorManager;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var adhoc:ArrayCollection = new ArrayCollection();
    [Bindable]
    public var serverString = "" ; 
          private function initImage(event:MouseEvent):void {
                  if(adhoc.length > 0){
                CursorManager.setBusyCursor();
              private function onChange():void{
          if(comboBox.selectedIndex == 0){
        }else{
              private function onChange1():void{
              if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                datepick.visible = true
                txt.visible = false
              }else{
              txt.visible = true
                datepick.visible = false
        private function add():void{
        var str:String = txt.text;
        if(str.length == 0 && txt.visible == true){
            Alert.show("Value Can Not Be Empty");
            return;
          if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
              if(txt.visible == true){
                  var temp:Object = new Object();
        temp.fname = combo2.selectedItem;
        temp.opera = combo1.selectedItem;
        temp.val = "'"+txt.text+"'";
            adhoc.addItem(temp);
              txt.text = "";
          var str1:String = datepick.text;
          if(comboBox.selectedIndex == 1){
            if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(str1.length == 0 && datepick.visible == true){
            Alert.show("Date Cannot Be Empty");
            }else{
            var temp:Object = new Object();
        temp.fname = combo2.selectedItem;
        temp.opera = combo1.selectedItem;
        temp.val = datepick.text;
              adhoc.addItem(temp);
              datepick.text = "";                   
        addbutton.enabled = false;
        addopenbracket.enabled = false;
        combo2.enabled = false;
        combo1.enabled = false;
        private function querydelete():void{
            if (AdHoc.selectedIndex > 0) {
                if(AdHoc.selectedIndex == (adhoc.length-1)){
              adhoc[AdHoc.selectedIndex-1].cond = "";
              addopenbracket.enabled = false;
              addclosebracket.enabled = false;
              addbutton.enabled = false;
              combo2.enabled = false;
              combo1.enabled = false;
              combo2.selectedItem = adhoc[adhoc.length-2].fname
              combo1.selectedItem = adhoc[adhoc.length-2].opera
                adhoc.removeItemAt(AdHoc.selectedIndex);
          //  adhocdetailgridcompilance.dataProvider = null ;
        //    adhocdetailgrid.dataProvider = null ;
            }else if (adhoc.length == 1) {
                adhoc.removeItemAt(AdHoc.selectedIndex);
          //  adhocdetailgridcompilance.dataProvider = null ;
        //    adhocdetailgrid.dataProvider = null ;
                addopenbracket.enabled = true;
              addclosebracket.enabled = true;
              addbutton.enabled = true;
              combo2.enabled = true;
              combo1.enabled = true;
            }else{
                Alert.show("Select The Rows To Delete");
          private function andSubmit():void{
            for each(var obj:Object in adhoc){
                if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                  if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(datepick.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
                }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
          addbutton.enabled = true;
          addopenbracket.enabled = true;
          combo2.enabled = true;
          combo1.enabled = true;
        private function orSubmit():void{
          for each(var obj:Object in adhoc){
                if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                  if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
              }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(datepick.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
          }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
                }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
          addbutton.enabled = true;
          addopenbracket.enabled = true;
          combo2.enabled = true;
          combo1.enabled = true;
          public function addOpenBracket():void{
                var temp:Object = new Object();
              temp.fname = addopenbracket.label
          adhoc.addItem(temp);
          addopenbracket.enabled = false
          addclosebracket.enabled = true
                if(adhoc.length > 1 && addopenbracket.enabled == false){
                    addbutton.enabled = true
        public function addCloseBracket():void{
              var temp:Object = new Object();
              if(adhoc.length > 1){
            temp.fname = addclosebracket.label
            adhoc.addItem(temp);
            addopenbracket.enabled = true
            addclosebracket.enabled = false
          if(adhoc.length > 1 && addclosebracket.enabled == false){
                    addbutton.enabled = true
        private function dateChange(date:Date):void{
            if (date == null){
              }else{
                    txt.text = date.getDate() + '/' + (date.getMonth()+1).toString() + '/' +
                              date.getFullYear().toString() ;
        public function saveadhoc(event:Event):void {
                var AdhocRows:String = "";
        var i:int ;
              var selectedType = comboBox.selectedItem;
              if(adhoc.length == 0){
              Alert.show("Enter The Query");
              }else{
        for(i = 0; i < adhoc.length;i++) {
          if(adhoc[i].fname != null){
          AdhocRows = AdhocRows +adhoc[i].fname+" ";
          if(adhoc[i].opera != null){
          AdhocRows = AdhocRows + adhoc[i].opera+" ";
          if(adhoc[i].val != null){
          AdhocRows = AdhocRows + adhoc[i].val+" ";
          if(adhoc[i].cond != null){
          AdhocRows = AdhocRows + adhoc[i].cond+" ";
            var parameters:Object = {adhocquery:AdhocRows,FlexActionType:"ADHOCQUERYSUBMIT",adhocType:selectedType};
              //  adhocClick.send(parameters);
            private function retrieve():void{         
                datepick.visible = false
              txt.visible = true
    ]]>
    </mx:Script>
            <mx:Array id="comp">
                <mx:String>TYPE</mx:String>
            <mx:String>AUDITRESULT</mx:String>
            <mx:String>CATEGORY</mx:String>
            <mx:String>CHILDRULE</mx:String>
            <mx:String>PARENTRULE</mx:String>
            <mx:String>AUDITGROUP</mx:String>
            <mx:String>LOCATION</mx:String>
            <mx:String>VENDOR</mx:String>
            <mx:String>DEVICECATEGORY</mx:String>
        </mx:Array>
        <mx:Array id="inven">
      <mx:String>VENDOR</mx:String>
      <mx:String>DEVICETYPE</mx:String>
      <mx:String>SERIES</mx:String>
      <mx:String>MODEL</mx:String>
      <mx:String>SUP/CPU</mx:String>
      <mx:String>CODEVERSION</mx:String>
      <mx:String>IMAGENAME</mx:String>
      <mx:String>DATEDEPLOYED</mx:String>
      <mx:String>LOCATIONNAME</mx:String>
      <mx:String>ADDRESS1</mx:String>
      <mx:String>ADDRESS2</mx:String>
      <mx:String>CITY</mx:String>
      <mx:String>STATE</mx:String>
      <mx:String>COUNTRY</mx:String>
      <mx:String>FLOOR</mx:String>   
      <mx:String>CABINET</mx:String>
      <mx:String>CATEGORYNAME</mx:String>
      <mx:String>DEPARTMENT</mx:String>
      <mx:String>CONTACTNAME</mx:String>
      <mx:String>CONTACTNUMBER</mx:String>
      <mx:String>VERSION</mx:String>
      <mx:String>FILENAME</mx:String>
      <mx:String>DATEUPLOADED</mx:String>
    </mx:Array>
    <mx:Accordion x="13" y="55" width="230" height="492">
    <mx:Form label="AdHoc Query Analyzer"  width="100%"  creationComplete="retrieve()" height="100%" color="#F2F8F9" backgroundColor="#020202">
      <mx:Canvas label="Query" width="204" height="440" backgroundColor="#020202">
      <mx:ComboBox x="66" y="287" width="134"  id="comboBox" dataProvider="[COMPLIANCE , INVENTORY]" change="onChange()" color="#050505">
      </mx:ComboBox>
      <mx:ComboBox x="5" y="344" width="109.25" id="combo1" dataProvider="[=,!=,>,>=,&lt;,&lt;=,LIKE]" color="#010101"></mx:ComboBox>
      <mx:TextInput x="119.25" y="344" width="77.75" id="txt" color="#050505"/>
        <mx:Button x="3" y="401" label="Add" width="59" click="add()" id="addbutton" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="66" y="401" label="Delete" width="63.25" click="querydelete()" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="2" y="373" label="("  id="addopenbracket" click="addOpenBracket()"  width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="51" y="373" label=")" id="addclosebracket" click="addCloseBracket()"  width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="134.25" y="401" label="Submit" click="saveadhoc(event);initImage(event)" color="#FFFEFE" fillAlphas="[1.0, 0.69, 0.75, 0.65]" fillColors="[#77B97A, #77B97A, #EEEEEE, #EEEEEE]" borderColor="#77B97A" themeColor="#009DFF"/>
      <mx:ComboBox x="66" y="317" width="134" id="combo2" change="onChange1()" dataProvider="{comp}" color="#010101">
      </mx:ComboBox>
      <mx:DateField x="122.25" y="344" width="74.75" initialize="dateChange((event.target).selectedDate)" id="datepick" color="#050505"/>
      <mx:DataGrid x="1" y="1" width="203" height="282" id="AdHoc" dataProvider="{adhoc}" allowMultipleSelection="true" color="#020202">
      <mx:columns>
        <mx:DataGridColumn headerText="Name" dataField="fname" id="fnam"/>
        <mx:DataGridColumn headerText="Operator" dataField="opera" id="ope"/>
        <mx:DataGridColumn headerText="Value" dataField="val" id="valu"/>
        <mx:DataGridColumn headerText="Condition" dataField="cond" id="condt"/>
      </mx:columns>
      </mx:DataGrid>
      <mx:Button x="99" y="373" label="AND" width="52" click="andSubmit()" id="and" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="154" y="373" label="OR" width="49" click="orSubmit()" id="or" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Label x="7" y="291" text="TYPE" width="59" fontWeight="bold"/>
      <mx:Label x="5" y="319" text="DISPLAY" width="59" fontWeight="bold"/>
        </mx:Canvas>
      </mx:Form>
    </mx:Accordion>
    </mx:Application>

    Ok... but I am a little confused (sorry to be a nuisance ),
    my delete function within my webService requires an ID to be
    passed from the Flex application, thus when a row is selected, the
    ID of the selected row is taken, so when the Delete button is
    pressed it sends this ID to the webService where it is taken and
    used - and therefore deleting the row etc.....
    Do you mean to define the result handler for the deleteOPG
    operation in the main webService tag, i.e. :
    <mx:WebService id="wsData" wsdl=http://...?wsdl>
    <mx:operation name="getRes" result="handleWSR(event)"/>
    <mx:operation name="deleteOPG"
    result="handleWSR_deleteOPG(event)"/>
    </mx:WebService>
    and then call it in my delete function, passing the ID from
    my delete function to my new result handler function ??? :
    Thanks,
    Jon.

  • Deleting a row from a Row Repeater

    Hi All,
    How could i delete a row from a row repeater??????
    I am using REMOVE_ELEMENT method from IF_WD_CONTEXT_NODE interface... Is this the correct way!!!!!!.
    Is there anyother way to do the same?????
    Best Regards.
    Shafiq Ahmed Khan.

    Hi
    first u get the index from the context element. with the help of the index u can get that particular element using get element.
    then u remove the element .
    check this code.
    CALL METHOD context_element->get_index
      receiving
        my_index = lv_index.
    CALL METHOD lo_nd_rcf_edu_det->get_element
      EXPORTING
        index        = lv_index
      receiving
        node_element = lo_el_rcf_edu_det .
    CALL METHOD lo_nd_rcf_edu_det->remove_element
      EXPORTING
        element          = lo_el_rcf_edu_det
    receiving
       has_been_removed =
    Declare a parameter context_element in the method of type if_wd_context_element
    regards
    chythanya

  • Deleting a row from matrix by context menu

    Hi all
    does anyone know how can i cause right click on mouse button. on a certain row within a matrix to show a context menu with the option to delete the row. and when pressing the menu item handling the event of deleting the row from the matrix?
    appreciate the help
    Yoav

    Hi Yoav,
    Simply, 'context menu' have to be handled with 'menu event' object.
    It can be done by 'flushToDataSource' method and some tricks.
    Basically, method delete the row without any clause of addon code.
    But it's only can be done in display side.
    If you're using DBDataSource, you have to flush to the datasource.
    I mean, you have to update datasource with the data displayed in the matrix.
    and then, delete the last row of the datasource.
    FlushToDataSource doesn't affect to the number of rows in the datasource.
    You have to delete a row with a method of DBDatasource.. I can't remember the name.
    If, the matrix uses userdatasource, you don't need to delete a row in datasource.
    Because userdatasource doesn't have a concept of 'row', actually.
    Hope this helpful for you.
    Regards,
    Hyunil Choi

Maybe you are looking for