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.
☺Bill

Similar Messages

  • How do "delete" the deleted project rows from the database

    My database has grown large due to "perf" testing and needs trimmed down. I have been deleting projects from the P6 Professional which marks the projects and associated data as "deleted" but does not actually delete them.
    How does one go about forcing the deletes from these tables. I think the DAMON or someother process "deletes" them but running DAMON does not help.
    How do I force these deletes so that I can test the performance with reasonable number of projects..

    You don't.
    You can restore from backup.  Everything from the time of the backup will be restored to the iphone.  Anything after that will be erased, however.

  • 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 do I remove a row from the database?

    Guys and Gals,
    I'm using Studio Edition Version 11.1.1.3.0.
    The code below will delete a row from my table, but how do I actually delete the row from the database as well?
        DCBindingContainer dcbc = (DCBindingContainer)getBindings();
        DCIteratorBinding dcib = dcbc.findIteratorBinding("TipsSelectorIterator");
        dcib.removeCurrentRow();
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable()); In this post, I believe Frank sums up what I should do: Remove row from af:table
    >
    The problem in your case is that this removes the row from the iterator but not your business service. EJB exposes explicit methods to remove an entity. A method lime removeEmployees(employee) >expsed on the EJB model must be called.
    You can drag and drop the "removeEmployees" method then as a button to your page. Rename the text label to "Remove" or "Delete". In the opened dialog box, point the method argument to the >following EL #{bindings.iteratorName.currentRow.dataProvider}. Next time you press the button, the row is deleted from the iterator and the business service
    Huh? So to delete the row, I need to expose a method. But where? Do I do this in the AppModuleImpl so I can expose it to the Client Interface? But then how do I access entities? And what data type is the #{bindings.iteratorName.currentRow.dataProvider}?
    If anyone could point me in a general direction, it'd be great.

    Frank and Shay,
    Thank you both for your posts. I'm amazed there's such a great place to get help. Between the forums, ADF code corner, Not Yet Documented ADF Samples, various blogs and tutorials, it's obvious you guys really care about what you do.
    On my example, that approach doesn't seem to work. I tried following it like so in one of the video tutorials by Shay: http://blogs.oracle.com/shay/2010/04/doing_two_declarative_operatio.html. Following Shay's approach, in my particular case, deletes only from the table. Perhaps it is due to my iterator / collection setup?
    TipsSelector (1 to 1) -> TipsView (1 to *)-> DependentBom -(1 to * Recursive)> RecursiveBom
    TipsSelector references the same View Object as TipsView, but it is set as a 1 to 1 relationship so that I can show TipsView on the page one record at a time. This is the same setup as Tuhra2's hierarchy veiwer example. TipsView / DependentBom is a classic parent / child setup. RecursiveBom is DependentBom referencing itself. Think of it as departments within departments within departments etc...
    I have dragged TipsSelector's Named Criteria (All Queriable Attributes) onto my page and created an ADF Query with Table. A remove button on the table's toolbar calls the two actions, Delete (from TipsSelector's iterator) and then Commit. I have modified the code slightly from my previous post but the end result seems to be the same.
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Delete");
        operationBinding.execute();
        bindings = getBindings();
        operationBinding = bindings.getOperationBinding("Commit");
        operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable());Page Def file
        <action id="Commit" InstanceName="AppModuleDataControl"
                DataControl="AppModuleDataControl" RequiresUpdateModel="true"
                Action="commitTransaction"/>
        <action IterBinding="TipsSelectorIterator" id="Delete"
                InstanceName="AppModuleDataControl.TipsSelector"
                DataControl="AppModuleDataControl" RequiresUpdateModel="false"
                Action="removeCurrentRow"/>On ppr of the query table, the row is gone. However, when I press the Search button on the query again, the record reappears.
    This is beyond me. Am I somehow deleting from the query results but not the database?

  • Getting error while deleting rows from the database using the View Object

    Hi All,
    I am using jdev 11.1.1.4.0. I am removing the rows from the database using viewobject( quering the viewobject to find the records i want to delete).
    I am using vo.removeCurrentRow(0). Before this statement I am able to get the rows I want to delete.
    after that i am doing am.transaction.commit(). But I am getting the error..
    javax.faces.el.EvaluationException: oracle.jbo.DMLException: JBO-26080: Error while selecting entity for CriteriaEO
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:58)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:879)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:312)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:185)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    Caused by: oracle.jbo.DMLException: JBO-26080: Error while selecting entity for CriteriaEO
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelectForAltKey(OracleSQLBuilderImpl.java:1117)
         at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelect(BaseSQLBuilderImpl.java:553)
         at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:8134)
         at oracle.jbo.server.EntityImpl.lock(EntityImpl.java:5863)
         at oracle.jbo.server.EntityImpl.beforePost(EntityImpl.java:6369)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6551)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3275)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3078)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2088)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2369)
         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.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         ... 53 more
    Caused by: java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:924)
         at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1261)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1419)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3752)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3806)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1667)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelectForAltKey(OracleSQLBuilderImpl.java:869)
    Please give suggestions...
    Thanks
    Kanika

    Hi,
    First Run Application module and confirm whether model project is OK,Cause for the Error is Caused by: java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long
    check:
    Issues with table/column name length
    identifier is too long
    I guess following error occurred because above issue
    JBO-26080: DMLException
    Cause: An unexpected exception occurred while executing the SQL to fetch data for an entity instance or lock it.
    Action: Fix the cause for the SQLException in the details of this exception.
    See:
    http://download.oracle.com/docs/cd/A97337_01/ias102_otn/buslog.102/bc4j/jboerrormessages.html#26080Hope you will helpful

  • 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() ;

  • 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 parent table

    Dear Guru's
    I am having two table with parent - child relationship. My problem is when I am deleting a row from parent table the curresponding child row from child table also should be deleted.
    My Primary table 'Employee, EMPID Primary key
    Child table 'Privilage' inthis EMPID referencing the EMPID of Employee table
    My need is when I am deleting a row from parent table the curresponding child row from child table also should be deleted
    I issued the SQL query like,
    delete from employee where empid='12345' cascade constraints;
    Then it showing me error like,
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    Please resolve my issue , Its Top urgent
    Thanks & Cheers
    Antony

    Choosing How Foreign Keys Enforce Referential Integrity
    Oracle Database allows different types of referential integrity actions to be enforced, as specified with the definition of a FOREIGN KEY constraint:
    Prevent Delete or Update of Parent Key The default setting prevents the deletion or update of a parent key if there is a row in the child table that references the key. For example:
    CREATE TABLE Emp_tab ( 
    FOREIGN KEY (Deptno) REFERENCES Dept_tab);Delete Child Rows When Parent Key Deleted The ON DELETE CASCADE action allows parent key data that is referenced from the child table to be deleted, but not updated. When data in the parent key is deleted, all rows in the child table that depend on the deleted parent key values are also deleted. To specify this referential action, include the ON DELETE CASCADE option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE CASCADE); Set Foreign Keys to Null When Parent Key Deleted The ON DELETE SET NULL action allows data that references the parent key to be deleted, but not updated. When referenced data in the parent key is deleted, all rows in the child table that depend on those parent key values have their foreign keys set to null. To specify this referential action, include the ON DELETE SET NULL option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE SET NULL);
    SQL> conn scott/tiger
    Connected.
    SQL> create table ppk ( no number primary key);
    Table created.
    SQL> begin for inn in 1..10 loop insert into ppk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> create table ffk ( no number references ppk(no));
    Table created.
    SQL> begin for inn in 1..10 loop insert into ffk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> drop table ppk cascade constraints;
    Table dropped.Message was edited by:
    user52
    Message was edited by:
    user52
    Message was edited by:
    user52

  • 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 a row from a table containing CLOB as one of the columns

    When i delete a row from a table which contains a CLOB (internal clob) i.e. CLOB or BLOB column, Will the CLOB data will also be deleted ? I understand that what exactly stored in the CLOB column is the clob locator which points to the actual data.
    So, when I delete this row, the clob locator will be deleted, but will the actual data what this locator is pointing to is also deleted ??? if not what is the process to delete the data the locator is pointing to when the row containing the locator is deleted ? If this is not happening then the actual data might become an orphan data which nobody has access to, will automatic garbage cleaning occurs on a frequent intravels to delete unaddressed data residing on the database server ?
    Thanks in advance for the help, can email me at [email protected] alternatively.
    Regards,
    Srinivasa C.

    Michael,
    Thanks very much for your inputs, here are the results i got when i tried the way you explained in your answer, the TRUNCATE command made the actual size back to normal, but the delete is not the same, so, how can i delete the data that a particular clob locator may point to ?
    truncate would delete all the rows of the table, which might not serve my purpose, i would like to delete a row and also it's associated clob data from the database! is there anyway to do this ?
    is there any limitation on the ool_sample size? i am basically a c++ programmer, i am looking for some function like FREE which would free the allocated memory to the clob once the locator is deleted.
    your help is greatly appreciated - Thanks!
    :-) Srini.
    ==========================
    My Results:
    ==========================
    SQL> create table sample (
    2 id integer primary key,
    3 the_data CLOB default empty_clob() )
    4 lob (the_data) store as ool_sample;
    Table created.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    20K
    SAMPLE
    10K
    SQL> select count(*) from sample;
    COUNT(*)
    0
    SQL> begin
    2 for i in 1..1000
    3 loop
    4 insert into sample values (i, RPAD('some data', 4000) );
    5 end loop;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> delete sample;
    1000 rows deleted.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> commit;
    Commit complete.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> begin
    2 for i in 1..1000
    3 loop
    4 insert into sample values (i, rpad('some data', 4000));
    5 end loop;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    9616K
    SAMPLE
    70K
    SQL> truncate table sample;
    Table truncated.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    20K
    SAMPLE
    10K

  • How to remove only one row from the database using labview6.1

    using labview 6.1 I create a table with various rows and columns and store bulk of data's in them.,, what procedure should I follow to remove only one paticular row from the database? Help me out with an example please,,
    Thanking you in advance!

    Hi,
    If you have the database toolkit you can delete a row using just a SQL Query to "DB Tools Execute Query.VI"
    Example:
    DELETE FROM Table name Where SerialNum='Value' And Date='Value' And Time='Value'
    See also attached VI
    Best Regards
    Johan
    Attachments:
    Delete_a_row_in_a_database_table.vi ‏48 KB

  • 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 a Procedure

    Hi All
    Can one of you tell me how to delete a row from a Procedure
    It is created with
    CREATE OR REPLACE PROCEDURE report.NAMEOFTABLE
    (nPutId IN Report.ID%TYPE,
    cArea IN Report.Area%TYPE,
    cSubject IN Report.Subject%TYPE,
    nUserId IN Report.EngineerID%TYPE,
    cDesc IN Report.Description%TYPE,
    cSide IN Report.SideEffects%TYPE,
    cImpact IN Report.Impact%TYPE,
    cNotes IN Report.Notes%TYPE,
    nValid IN Report.Valid%TYPE) AS
    -- Add or update Report
    -- If nId < 1 then a record is added, otherwise updated.
    BEGIN
    IF nId < 1 THEN
    INSERT INTO Report
    (Area, Subject, EngineerID,
    Description, SideEffects, Impact,
    ReportNotes, Valid)
    VALUES
    (cArea, cSubject, nUserId, cDesc, cSide, cImpact, cNotes, nValid);
    ELSE
    UPDATE Report
    SET ReportArea = cArea,
    ReportSubject = cSubject,
    ReportDescription = cDesc,
    ReportSideEffects = cSide,
    ReportImpact = cImpact,
    ReportNotes = cNotes,
    ReportValid = nValid
    WHERE ReportID = nPutId;
    END IF;
    COMMIT;
    END;
    CREATE SYNONYM Admin.NAMEOFTABLE
    Report.NAMEOFTABLE;
    But I need to make 1 field of the impact and the sideEffect called the ImpactEffect
    So how do i delete the field of Side effect and change the name of the Impact field.
    Sould I make a new Procedure?

    If you want to delete a row, you'd need a DELETE statement. It is not obvious to me, though, that you really want to delete a row. It sounds like you're trying to update a row, and there is an UPDATE statement in the procedure. Unfortunately, I'm very unsure exactly what you're trying to accomplish and how this procedure relates to that goal. Perhaps if you could post the starting state of the row, the procedure call you're trying to make, and the end state of that row, things might be much clearer.
    As an aside, do you really have a schema and a table named REPORT? That seems rather confusing.
    Justin

  • Deleting a row from a table control through right-clic​k menu

    I have a table control. I want to delete a row from it when a user right clicks on a particular row and selects "Delete row" menu item. I have managed the creation of menu item but have not been able to delete the row which is right clicked and the menu item "Delete row" is selected. Guidance required! Thanks!

    smercurio_fc wrote:
    It's irrelevant whether the table is a control or indicator. See attached VI.
    Hi smercurio,
    please see the attached picture. In my previous post i mean the different in the menu. The red marked function is not available, if the table is an indicator. LV8.5!
    Mike
    Message Edited by MikeS81 on 04-18-2008 05:19 PM
    Attachments:
    Unbenannt.PNG ‏22 KB

Maybe you are looking for

  • Image repaint preformance and threading

    Folks, I'm trying to make this sucker run faster. My question is, can anyone please guide me, especially with regards synchronising the Threads more efficiently... I'm thinking of using join and i]notify to make the "navigator" threads yield to the s

  • Linked PDF file won't preview in Safari

    I linked a PDF file to my iWeb page but when I click on it in Safari it loads almost to the end but then errors at the last two pages. The same file works fine in Mac Firefox and IE on a few PC's I tried. Safari though on multiple macs just wouldn't

  • AR,GL and profit center relation

    Hi, We have a requirement to report profit center wise amount. aageing analysis. At present we are not loading Profit center through AR. So we are doing a look up to get the profit center on GL. So can you please let me knoew the relation betwen the

  • Sequential read

    Hi all, I have got a request from the basis team to check why a particular program is doing a sequential read. How should i go ahead for the request. I am unable to find where the program is doing sequential reads. Can anyone tell me how to look for

  • My application storage is 63gb but system information says i still have 95gb free out of 120gb

    Help needed. Was checking my storage capacity at the About this Mac and it says i have 63 gb of storage for application. What's weird is that it still say i have 95 gb of free storage out of 120gb. Apparently that 63 gb storage increases by 1.5 gb ev