Deleting a row from a resultSet with nulls
Hello All,
I have stumbled across a bit of a problem when using a cachedRowSet
If I select columns from my database that have null values, and I call deleteRow() I get a
NullPointerException.
at com.sun.rowset.internal.CachedRowSetWriter.deleteOriginalRow
However if I don�t select the null columns in my cachedRowSet. I can delete no worries.
I would of though that the cachedRowSet object could handle nulls but it seems it doesn�t, anyone know any workarounds for this?
NOTE: using JTDS driver would that play a part?
If I select columns from my database that have null
values, and I call deleteRow() I get a Does the whole row a null record ?
Please put a sample program so that the problem can be reproduced.
>
NullPointerException.
at
com.sun.rowset.internal.CachedRowSetWriter.deleteOrigi
nalRow
Also give the stack trace.
Similar Messages
-
Oracle deleting rows from tables starting with the name PQ
hai friends
we are given access rights to delete only tables starting with PQ. HAVING PQ_NUM as primary key for all the PQ tables.
totally we have 6 tables. PQ_01,PQ_02, PQ_03,PQ_04,PQ_05,PQ_06.
ALL This tables will have one primary key. for example pq_01 willl have pq01_num as primarykey and pq_02 table will have pq02_num as primary
key.
pq01_num value will exist in all the primary key of pq tables.
i want query to delete rows from the pq tables based on the input value i give.
for example if i give primarykey value 122 then that value in pq tables should be deleted.
One more problem is there. pq_06 table does not have pq02_num column. here the column differs. it is pq06_num_req.
so give your idea of deleting the rows from pq tables
waiting
SI dont have access to databse,this is untested
declare
v_cmd varchar2(2000);
columnname varchar2(30);
input_value number:=??;
tabowner varchar2(30):=???
begin
--step 1 identify table
FOR sub IN (SELECT table_name table_to_delete
FROM all_tables
WHERE table_name LIKE 'PQ%'
and owner=tabowner
) LOOP
----step 2 identify column
v_cmd :='select t.column_name from all_constraints S,All_Ind_Columns T where
S.OWNER=T.TABLE_OWNER
AND S.TABLE_NAME=T.TABLE_NAME
AND S.INDEX_NAME=T.INDEX_NAME
and s.owner=tabowner
AND S.TABLE_NAME='||table_to_delete||'
and s.constraint_type='''P'';
execute immediate v_cmd into columnname;
--step 3 delete records
v_cmd := 'delete from '||tabowner||'.' ||
sub.table_to_delete || '
where '||columnname||'='||input_value;
execute immediate v_cmd;
commit;
END LOOP;
end;Edited by: user5495111 on Aug 11, 2009 6:35 AM -
Adding/deleting rows from a treeTable with a read-only view object
Hello --
I'm getting a JBO-25016 error when I go to delete a row from a treeTable. I want to create the hierarchy from a stored procedure, have the user add and remove nodes without calling back to the database. I will iterate through the tree and see what has changed and made the necessary updates on the database manually.
What is the correct method for adding/removing rows form the UI component?
Thanks!
TomThank you, Amit! That did the trick.
Edited by: Tom on Apr 28, 2011 11:51 AM -
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 -
I am trying to delete a row from a JTable whenever the button on the last column is pressed. I know to do this, I can use the removeRow(int) method of the tableModel. But the odd thing is when I try to get a handle to the TableModel from the JTable to use that function, i.e. table.getModel().removeRow(int) it doesn't work. But if I explicitly pass in the tableModel into my class it does work. Here's the code below:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.AbstractCellEditor;
import javax.swing.table.DefaultTableModel;
public class tester4 extends JFrame
protected final int BUTTON_COL = 2;
private TableCellRenderer defaultRenderer;
private TableCellEditor defaultEditor;
private JTable workingTable;
private String[] transactionCols = {"Qty", "Product", "Cancel"};
private Object[][] data = {{5, "prod1", "Cancel"},
{6, "prod2", "Cancel"},
{7, "prod3", "Cancel"}};
public tester4()
workingTable = new JTable(tableModel);
workingTable.setName("Working Table");
defaultRenderer = workingTable.getDefaultRenderer(JButton.class);
defaultEditor = workingTable.getDefaultEditor(Object.class);
StatusTableRenderer testRenderer = new StatusTableRenderer(defaultRenderer, defaultEditor, workingTable, tableModel);
workingTable.setDefaultRenderer(Object.class, testRenderer);
workingTable.setDefaultEditor(Object.class, testRenderer);
JScrollPane scrollPane = new JScrollPane( workingTable );
getContentPane().add( scrollPane );
private DefaultTableModel tableModel = new DefaultTableModel(data, transactionCols){
// Only allow button column to be editable, if there is an actual
// button in that row
public boolean isCellEditable(int row, int col){
return (col == BUTTON_COL && data[row][col] != "") ? true : false;
// Overriden getColumnClass method that will return the object
// class type of the first instance of the data type otherwise
// returns the Object.class
public Class getColumnClass(int column){
for (int row = 0; row < getRowCount(); row++){
Object o = getValueAt(row, column);
if (o != null){ return o.getClass(); }
return Object.class;
public static void main(String[] args)
tester4 frame = new tester4();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
public class StatusTableRenderer extends AbstractCellEditor
implements TableCellRenderer,
TableCellEditor,
ActionListener{
private TableCellRenderer defaultRenderer;
private TableCellEditor defaultEditor;
private JButton cancelButton;
private JButton editButton;
private String text;
private int buttonColumn;
private int selectedRow;
private JTable table;
private DefaultTableModel tableModel;
public StatusTableRenderer(TableCellRenderer renderer,
TableCellEditor editor,
JTable table,
DefaultTableModel tableModel){
defaultRenderer = renderer;
defaultEditor = editor;
this.table = table;
this.tableModel = tableModel;
buttonColumn = table.getColumnCount() - 1;
cancelButton = new JButton();
editButton = new JButton();
editButton.setFocusPainted(true);
editButton.addActionListener(this);
public StatusTableRenderer(TableCellRenderer renderer,
TableCellEditor editor,
JTable table,
DefaultTableModel tableModel,
int _buttonColumn){
this(renderer, editor, table, tableModel);
buttonColumn = _buttonColumn;
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (column == buttonColumn){
if (hasFocus){
cancelButton.setForeground(table.getForeground());
cancelButton.setBackground(UIManager.getColor("Button.background"));
else if (isSelected){
cancelButton.setForeground(table.getSelectionForeground());
cancelButton.setBackground(table.getSelectionBackground());
else{
cancelButton.setForeground(table.getForeground());
cancelButton.setBackground(UIManager.getColor("Button.background"));
cancelButton.setText( (value == null) ? "" : value.toString() );
return cancelButton;
return defaultRenderer.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column){
if (column == buttonColumn){
text = ((value == null) ? "": value.toString());
editButton.setText(text);
selectedRow = row;
return editButton;
return defaultEditor.getTableCellEditorComponent(
table, value, isSelected, row, column);
public Object getCellEditorValue()
return text;
public void actionPerformed(ActionEvent e)
fireEditingStopped();
// This works
tableModel.removeRow(selectedRow);
// This does not work
// table.getModel().removeRow(selectedRow);
}Take a look at the actionPerfformed method. One way of doing it works, one doesn't. Just trying to understand why me getting a handle to the tableModel through the table doesn't work.
Message was edited by:
deadseasquirrelsIt gives me a run-time error Well then your question should be "why do I get this run-time error" and then you would quote the error. Be more descriptive. "It doesn't work" is not descriptive.
table.getModel().removeRow(selectedRow);I don't use JDK1.5 either. But if you are saying that the above line compiles cleanly with JDK1.5 (because of the auto-boxing feature, or whatever its called), then I see no reason why the code wouldn't work since it recognizes the class as a DefaultTableModel.
Presumably you commented out the other line so you don't try to delete the row twice. Otherwise you might be getting a indexing error. -
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 -
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
AntonyChoosing 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> -
Delete many rows from one table at once URGENT
Assume we have table called emp.
table desription:
SQL> desc emp
Name Null? Type
EMPNO NOT NULL NUMBER(6)
DIVISION NOT NULL NUMBER(3)
JOB_NO NOT NULL NUMBER(4)
START_DATE NOT NULL DATE
select * from emp;
EMPNO--------DIVISION--------JOB_NO------------START_DATE
1111------------------011-------------8181--------------04/10/1999
1111------------------011-------------8181--------------04/10/2004
2222------------------011-------------3131--------------05/11/2005
3333-----------------022-------------8181--------------06/09/2001
3333-----------------044-------------8181--------------06/08/1988
5555-----------------011-------------8066--------------01/01/2001
6666-----------------033-------------9600--------------01/01/1999
7777-----------------044-------------8181--------------06/24/1996
7777-----------------033-------------8181--------------12/02/1991
7777-----------------033-------------8181--------------03/01/2002
9999-----------------044-------------9191--------------03/05/1980
9999-----------------055-------------9191--------------03/06/1989
My goal is to delete employee records for those employee which contains multiple values for JOB_NO
equal to 8181, (JOB_NO= 8181) with new start_dateS.
We need to keep only one record for JOB_NO 8181 which contains oldest start_date.
Here is the delete statement for the single record.
delete from emp
where empno = 7777 and job_no = 8181 and start_date in ('03/01/2002','06/24/1996);
So how could I delete thousands records from the table with this logic?
After deleting multiple records table should be as below:
select * from emp;
EMPNO--------DIVISION--------JOB_NO---------START_DATE
1111-----------------011-------------8181--------------04/10/1999
2222-----------------011-------------3131--------------05/11/2005
3333-----------------044-------------8181--------------06/08/1988
5555-----------------011-------------8066--------------01/01/2001
6666-----------------033-------------9600--------------01/01/1999
7777-----------------033-------------8181--------------12/02/1991
9999-----------------044-------------9191--------------03/05/1980
9999-----------------055-------------9191--------------03/06/1989Here's one way to do it. I think this fits your business rules. At least it matches the output for your first example. It uses an analytic. I just like using them.
SQL> select * from employees;
EMPNO DIVISION JOB_NO START_DATE
1111 11 8181 10-APR-1999
1111 11 8181 10-APR-2004
2222 11 3131 11-MAY-2005
3333 22 8181 09-JUN-2001
3333 44 8181 08-JUN-1988
5555 11 8066 01-JAN-2001
6666 33 9600 01-JAN-1999
7777 44 8181 24-JUN-1996
7777 33 8181 02-DEC-1991
7777 33 8181 01-MAR-2002
9999 44 9191 05-MAR-1980
9999 55 9191 06-MAR-1989
12 rows selected.
SQL> delete employees
2 where rowid in
3 (select rowid
4 from
5 (
6 select empno
7 ,job_no
8 ,start_date
9 ,row_number() over (partition by empno, job_no order by start_date) rn
10 from employees
11 where job_no = 8181
12 )
13 where rn > 1
14 )
15 ;
4 rows deleted.
SQL> select * from employees;
EMPNO DIVISION JOB_NO START_DATE
1111 11 8181 10-APR-1999
2222 11 3131 11-MAY-2005
3333 44 8181 08-JUN-1988
5555 11 8066 01-JAN-2001
6666 33 9600 01-JAN-1999
7777 33 8181 02-DEC-1991
9999 44 9191 05-MAR-1980
9999 55 9191 06-MAR-1989
8 rows selected. -
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 !
Rachelthe 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() ; -
How to delete the row in table control with respect to one field in module pool programming?
Hi,
Can I know the way to delete the row in table control with respect to one field in module pool programming
Regards
Darshan MSHI,
I want to delete the row after the display of table control. I have created push button as delete row. If I click on this push button, the selected row should get deleted.
I have written this code,
module USER_COMMAND_9000 input.
DATA OK_CODE TYPE SY-UCOMM.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'DELETE'.
LOOP AT lt_source INTO ls_source WHERE mark = 'X'.
APPEND LS_SOURCE TO LT_RESTORE.
DELETE TABLE LT_SOURCE FROM LS_SOURCE.
SOURCE-LINES = SOURCE-LINES - 1.
ENDLOOP.
But I'm unable to delete the selected rows, It is getting deleted the last rows eventhough I select the other row.
So I thought of doing with respect to the field. -
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 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
YoavHi 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
-
How to check the resolution of a pdf file using Acrobat 9 pro?
How to check the resolution of a pdf file using Acrobat 9 pro?
-
Hi, the subject says it all. I have downloaded the trail version to see if its possible to create a editable pdf with validation(required field) using Adobe Acrobat pro version? Basically, I will have to create a pdf form where users fill it and send
-
IPhoto '11 and RAW/JPEG handling (good/bad) ?
I've upgraded to iPhoto '11 and discovered (don't know if it's a new feature) that iPhoto handles RAW extremely well. I can view RAW files and edit etc in a smooth manner - which is great. Actually it's so great that i've started shooting photos in R
-
Recently I launched a new project to electronically document our IT infrastructure, procedures, policies, etc. During this, I realized that I could also provide this as a service/system to other groups within the organization for similar purposes (th
-
VB Error - Runtime error '49' Bad DLL calling convention
Hi Experts, When User is running report he is getting error VB Error - Runtime error '49' Bad DLL calling convention . Can you please suggest how to resolve this issue? User has already tried uninstalling SAP GUI and installing again. Thanks & Rega