Problem of deletion of rows in jtable, table refreshing too
Hi,
I have a table with empty rows in the beginning with some custom properties( columns have fixed width...), later user would be adding to the rows to this table and can delete, I've a problem while deleting the rows from table,
When a selected row is deleted the model is also deleting the data but the table(view) is not refreshed.
Actually i'm selecting a cell of a row, then hitting the delete button.
So the model is deleting the information, but i'm not able to c the fresh data in table( especially when the last cell of last row is selectd and hit the delete button, i am getting lots of exception)
Kindly copy the below code and execute it, and let me know,
* AuditPanel.java
* Created on August 30, 2002, 3:05 AM
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.Vector;
* @author yaman
public class AuditPanel extends javax.swing.JPanel {
// These are the combobox values
private String[] acceptenceOptions;
private Vector colNames;
private Color rowSelectionBackground = Color.yellow;
private int rowHeight = 20;
private int column0Width =70;
private int column1Width =96;
private int column2Width =327;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
/** Creates new form AuditPanel */
public AuditPanel() {
public void renderPanel(){
initComponents();
public String[] getAcceptenceOptions(){
return acceptenceOptions;
public void setAcceptenceOptions(String[] acceptenceOptions){
this.acceptenceOptions = acceptenceOptions;
public Vector getColumnNames(){
return colNames;
public void setColumnNames(Vector colNames){
this.colNames = colNames;
public Vector getData(){
Vector dataVector = new Vector();
/*dataVector.add(null);
dataVector.add(null);
dataVector.add(null);
return dataVector;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jTable1 = new javax.swing.JTable();
setLayout(new java.awt.GridBagLayout());
setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
jPanel2.setLayout(new java.awt.GridBagLayout());
jPanel2.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
jButton1.setText("Add");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 8;
gridBagConstraints.insets = new java.awt.Insets(0, 1, 5, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jPanel2.add(jButton1, gridBagConstraints);
jButton2.setText("Delete");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jPanel2.add(jButton2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
add(jPanel2, gridBagConstraints);
jPanel1.setLayout(new java.awt.GridBagLayout());
jPanel1.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED, Color.black, Color.gray) );
jTable1.setModel(new javax.swing.table.DefaultTableModel(getData(), getColumnNames()));
// get all the columns and set the column required properties
java.util.Enumeration enum = jTable1.getColumnModel().getColumns();
while (enum.hasMoreElements()) {
TableColumn column = (TableColumn)enum.nextElement();
if( column.getModelIndex() == 0 ) {
column.setPreferredWidth(column0Width);
column.setCellEditor( new ValidateCellDataEditor(true) );
if( column.getModelIndex() == 1) {
column.setPreferredWidth(column1Width);
column.setCellEditor(new AcceptenceComboBoxEditor(getAcceptenceOptions()));
// If the cell should appear like a combobox in its
// non-editing state, also set the combobox renderer
//column.setCellRenderer(new AcceptenceComboBoxRenderer(getAcceptenceOptions()));
if( column.getModelIndex() == 2 ) {
column.setPreferredWidth(column2Width); // width of column
column.setCellEditor( new ValidateCellDataEditor(false) );
jScrollPane1 = new javax.swing.JScrollPane(jTable1);
jScrollPane1.setPreferredSize(new java.awt.Dimension(480, 280));
jTable1.setMinimumSize(new java.awt.Dimension(60, 70));
//jTable1.setPreferredSize(new java.awt.Dimension(300, 70));
//jScrollPane1.setViewportView(jTable1);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
jPanel1.add(jScrollPane1, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add(jPanel1, gridBagConstraints);
// set the row height
jTable1.setRowHeight(rowHeight);
// set selection color
jTable1.setSelectionBackground(rowSelectionBackground);
// set the single selection
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// avoid table header to resize/ rearrange
jTable1.getTableHeader().setReorderingAllowed(false);
jTable1.getTableHeader().setResizingAllowed(false);
// Table header font
jTable1.getTableHeader().setFont( new Font( jTable1.getFont().getName(),Font.BOLD,jTable1.getFont().getSize() ) );
jButton1.setMnemonic(KeyEvent.VK_A);
// action of add button
jButton1.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
// If a button press is the trigger to leave a JTable cell and save the data in model
if(jTable1.isEditing() ){
//System.out.println("table is edition ");
String text=((javax.swing.text.JTextComponent)jTable1.getEditorComponent()).getText();
jTable1.setValueAt(text,jTable1.getSelectedRow(),jTable1.getSelectedColumn()) ;
jTable1.getCellEditor().cancelCellEditing();
// find out total available rows
int totalRows = jTable1.getRowCount();
int cols = jTable1.getModel().getColumnCount();
if( jTable1.getModel() instanceof DefaultTableModel ) {
((DefaultTableModel)jTable1.getModel()).addRow(new Object[cols]);
int newRowCount = jTable1.getRowCount();
// select the first row
jTable1.getSelectionModel().setSelectionInterval(newRowCount-1,newRowCount-1);
jButton2.setMnemonic(KeyEvent.VK_D);
// action of Delete button
jButton2.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
int totalRows = jTable1.getRowCount();
// If there are more than one row in table then delete it
if( totalRows > 0){
int selectedOption = JOptionPane.showConfirmDialog(null,"Are you sure you want to delete this audit row?","Coeus", JOptionPane.YES_NO_OPTION);
// if Yes then selectedOption is 0
// if No then selectedOption is 1
if(0 == selectedOption ){
// get the selected row
int selectedRow = jTable1.getSelectedRow();
System.out.println("Selected Row "+selectedRow);
if( selectedRow != -1 ){
DefaultTableModel dm= (DefaultTableModel)jTable1.getModel();
java.util.Vector v1=dm.getDataVector();
System.out.println("BEFOE "+v1);
v1.remove(selectedRow);
jTable1.removeRowSelectionInterval(selectedRow,selectedRow);
System.out.println("After "+v1);
}else{
// show the error message
JOptionPane.showMessageDialog(null, "Please Select an audit Row", "Coeus", JOptionPane.ERROR_MESSAGE);
} // end of initcomponents
class AcceptenceComboBoxRenderer extends JComboBox implements TableCellRenderer {
public AcceptenceComboBoxRenderer(String[] items) {
super(items);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(rowSelectionBackground);
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
// Select the current value
setSelectedItem(value);
return this;
class AcceptenceComboBoxEditor extends DefaultCellEditor {
public AcceptenceComboBoxEditor(String[] items) {
super(new JComboBox(items));
} // end editor class
public class ValidateCellDataEditor extends AbstractCellEditor implements TableCellEditor {
// This is the component that will handle the editing of the
// cell value
JComponent component = new JTextField();
boolean validate;
public ValidateCellDataEditor(boolean validate){
this.validate = validate;
// This method is called when a cell value is edited by the user.
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int rowIndex, int vColIndex) {
if (isSelected) {
component.setBackground(rowSelectionBackground);
// Configure the component with the specified value
JTextField tfield =(JTextField)component;
// if any vaidations to be done for this cell
if(validate){
//tfield.setDocument(new JTextFieldFilter(JTextFieldFilter.NUMERIC,4));
tfield.setText( ((String)value));
// Return the configured component
return component;
// This method is called when editing is completed.
// It must return the new value to be stored in the cell.
public Object getCellEditorValue() {
return ((JTextField)component).getText();
// This method is called just before the cell value
// is saved. If the value is not valid, false should be returned.
public boolean stopCellEditing() {
String s = (String)getCellEditorValue();
return super.stopCellEditing();
public void itemStateChanged(ItemEvent e) {
super.fireEditingStopped();
}//end of ValidateCellDataEditor class
public static void main(String args[]){
JFrame frame = new JFrame();
AuditPanel auditPanel = new AuditPanel();
frame.getContentPane().add(auditPanel);
auditPanel.setAcceptenceOptions(new String[]{"Accepted", "Rejected", "Requested"} );
java.util.Vector colVector = new java.util.Vector();
colVector.add("Fiscal Year");
colVector.add("Audit Accepted");
colVector.add("Comment" );
auditPanel.setColumnNames( colVector);
auditPanel.renderPanel();
frame.pack();
frame.show();
Hi,
I've got the solution for it. As when the cursor is in cell of
a row and hit the delete button, the data in that cell is not saved,
So i'm trying to save the data first into the model then firing the action event by doing this ..
jButton2.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
// If a button press is the trigger to leave a JTable cell and save the data in model
if(jTable1.isEditing() ){
String text=((javax.swing.text.JTextComponent)jTable1.getEditorComponent()).getText();
jTable1.setValueAt(text,jTable1.getSelectedRow(),jTable1.getSelectedColumn()) ;
jTable1.getCellEditor().cancelCellEditing();
// HERE DO THE DELETE ROW OPERATION
<yaman/>
Similar Messages
-
Problem in deleting the rows in a table
I am trying to delete 1213 records from a table.
When I am selecting the rows are selected within seconds.
When I am trying to delete the same rows, the script hangs, can anybody, help in finding the issue here!Or that there are some foreign keys defined without indexes that are forcing Oracle to do 1213 full table scans on some large child table to ensure that the data you're deleting isn't referenced by some other row.
Justin -
Deleting 1 row from a table takes too long...why?
We are running the following query...
delete gemdev.lu_messagecode where mess_code ='SSY'
and it takes way too long as there is only 1 record in this table with SSY as the mess_code.
SQL> set timing on;
SQL> delete gemdev.lu_messagecode where mess_code ='SSY';
1 row deleted
Executed in 293.469 seconds
The table structure is very simple as you can see below.
CREATE TABLE GEMDEV.LU_MESSAGECODE
MESS_CODE VARCHAR2(3) NOT NULL,
ROUTE_CODE VARCHAR2(4) NULL,
REPORT_CES_MNEMONIC VARCHAR2(3) NULL,
CONSTRAINT SYS_IOT_TOP_52662
PRIMARY KEY (MESS_CODE)
VALIDATE
ORGANIZATION INDEX
NOCOMPRESS
TABLESPACE IWORKS_IOT
LOGGING
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE(BUFFER_POOL DEFAULT)
PCTTHRESHOLD 50
NOPARALLEL
ALTER TABLE GEMDEV.LU_MESSAGECODE
ADD CONSTRAINT LU_ROUTECODE_FK3
FOREIGN KEY (ROUTE_CODE)
REFERENCES GEMDEV.LU_ROUTECODE (ROUTE_CODE)
ENABLE
ALTER TABLE GEMDEV.LU_MESSAGECODE
ADD CONSTRAINT MSGCODE_FK_CESMNEMONIC
FOREIGN KEY (REPORT_CES_MNEMONIC)
REFERENCES GEMDEV.SYS_CESMNEMONIC (CES_MNEMONIC)
ENABLE
My explain reads as follows.
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | DELETE STATEMENT | | | | 1 (100)| |
| 1 | DELETE | LU_MESSAGECODE | | | | |
| 2 | INDEX UNIQUE SCAN| SYS_IOT_TOP_52662 | 1 | 133 | 1 (0)| 00:00:01 |
Also in my AWR Sql Report I see this as well
Plan Statistics DB/Inst: IWORKSDB/iworksdb Snaps: 778-780
-> % Total DB Time is the Elapsed Time of the SQL statement divided
into the Total Database Time multiplied by 100
Stat Name Statement Per Execution % Snap
Elapsed Time (ms) 521,102 N/A 12.0
CPU Time (ms) 73,922 N/A 5.1
Executions 0 N/A N/A
Buffer Gets 2,892,144 N/A 3.4
Disk Reads 2,847,609 N/A 8.6
Parse Calls 1 N/A 0.0
Rows 0 N/A N/A
User I/O Wait Time (ms) 475,882 N/A N/A
Cluster Wait Time (ms) 0 N/A N/A
Application Wait Time (ms) 0 N/A N/A
Concurrency Wait Time (ms) 2 N/A N/A
Invalidations 1 N/A N/A
Version Count 1 N/A N/A
Sharable Mem(KB) 45 N/A N/A
Now, since the table only has 150 rows, and I am only try to delete 1 row, why is there so much disk read and why does it take 5 minutes to delete? This just weird. Does this have something to do with the Child tables?Any triggers on the table?
If you trace the session, what statement(s) seem to
be taking all that time?
JustinWell I traced my session and I noticed that my query does take a while, but I also noticed several other queries that I was not running. Not too sure where it came from. Have a look below. It is a sample from my TKPROF utility report.
delete gemdev.lu_messagecode
where
mess_code ='SSY'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.01 0.04 0 2 23 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.01 0.04 0 2 23 1
Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: 57
Rows Row Source Operation
1 DELETE LU_MESSAGECODE (cr=3446672 pr=3442028 pw=0 time=309363335 us)
1 INDEX UNIQUE SCAN SYS_IOT_TOP_52662 (cr=2 pr=0 pw=0 time=35 us)(object id 52663)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 35.87 35.87
select /*+ all_rows */ count(1)
from
"GEMDEV"."TBLCLAIMCHARGE" where "CONTRACT_FEE_MESS_CODE" = :1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 10.53 44.95 381779 382893 0 1
total 3 10.53 44.95 381779 382893 0 1
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 SORT AGGREGATE (cr=382893 pr=381779 pw=0 time=44953436 us)
0 TABLE ACCESS FULL TBLCLAIMCHARGE (cr=382893 pr=381779 pw=0 time=44953403 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 47795 0.03 37.87
db file sequential read 101 0.00 0.02
select /*+ all_rows */ count(1)
from
"GEMDEV"."TBLCLAIMCHARGE" where "FEE_INEL_MESS_CODE" = :1 -
How to delete a row in the table in servlets
I have met a problem in deleting a row in table using servlets.
My table looks like this:
ID Name Type
12 Milienium S
15 USIA O
My code looks like this:
String query = "SELECT * FROM tb_Funds";
rs = statement.executeQuery(query);
while(rs.next()) {
StdID=rs.getString("FundID");
StdName=rs.getString("Name");
StdType=rs.getString("Type");
out.print("<td><INPUT TYPE=TEXT NAME=
myName VALUE=" + StdID + "></td>");
out.print("<td>" + StdName + "</td>");
out.print("<td>" + StdType + "</td>");
buf.append("<td>" + "<INPUT TYPE=SUBMIT
NAME=Delete VALUE=DELETE>" + "</td></tr>");
There is a delete button in every row. May I know how to delete the row that I want by getting the ID from the table and delete it from the database.
Deleting from a table is simple -> delete from tb_funds where id = <value>. Obviously replace <value> with the appropriate ID or use a bind variable (a ?) and prepared statements.
Are you asking how to pass the id associated with the table row from the browser when the button is pressed? -
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 -
Problems with Click a row in the Table
Dear All,
I am new to Java GUI. I got some problems with clicking the row in a table.
My table allows the user to delete some rows fromt the table. When the user click a row or some rows in my table, the delete button should be enabled. It does work in most of the time. But sometimes, even the row being hight lighted, the button is still not enabled.
Do you have any idea for what can cause this problem?
What I did is :
1. add a mouse listener to the table
_userTable.addMouseListener(new java.awt.event.MouseAdapter()
public void mouseClicked(MouseEvent e)
userList_mouseClicked(e);
2. then, if the row being selected is > 0, I will enable my delete button.
Can anybody help?
Thanks!Dear All,
I am getting problems with single selection in a table. Although I have set the selection model to single, if I select a row int the table and then depress Ctrl/Shift multiple rows are selected.
The code for set single selection is :
ListSelectionModel seleModel = myTable.getSelectionModel();
seleModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Any idea about this? Is this a bug in JAVA?
Thanks! -
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 -
Issue while deleting a row from a table
Dear friends,
i am getting an issue while deleting a row from a table, pls check screen shots , the first screen shot is my table contents
when i delete 2 row , the second row is deleting properly like below screen shot
but i want like below screen shot , Col1 contents should be like pic 1 . could any one pls let me know how to solve this issue.
Thanks
VijayaHi vijaya,
please try this code, it will help you.
DATA : it_rows TYPE wdr_context_element_set,
wa_rows LIKE LINE OF it_rows.
DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lt_table TYPE wd_this->elements_table.
DATA lo_el_table TYPE REF TO if_wd_context_element.
DATA ls_vbap TYPE wd_this->element_table.
DATA: ld_index TYPE i.
data value TYPE sy-index.
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table= wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
* get element via lead selection
* alternative access via index
* lo_el_table = lo_nd_table->get_element( index = 1 ).
* @TODO handle not set lead selection
IF lo_el_table IS INITIAL.
ENDIF.
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
lo_nd_table->get_static_attributes_table( IMPORTING table = lt_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
** @TODO compute values
** e.g. call a model function
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
** @TODO compute values
** e.g. call a model function
it_rows = lo_nd_table>get_selected_elements( ).
CALL METHOD lo_nd_table->GET_LEAD_SELECTION_INDEX
RECEIVING
INDEX = value .
LOOP AT it_rows INTO wa_rows.
CALL METHOD wa_rows->get_static_attributes
IMPORTING
static_attributes = ls_table.
READ TABLE lt_table INTO ls_table WITH KEY col1 = ls_table-col1.
ld_index = value.
ENDLOOP.
CLEAR : ls_table-col2,
ls_table-col2.
MODIFY lt_table INDEX ld_index FROM ls_table.
lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ). -
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 youHi,
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. -
I have read two articles how to use sql adapter with delete.
http://btsguru.blogspot.se/2011/10/wcf-sql-adapter-table-operations.html
http://social.technet.microsoft.com/wiki/contents/articles/29146.biztalk-server-2013-crud-operation-with-wcf-sql-adapter-and-correlation.aspx?wa=wsignin1.0
Is it a way to delete all rows in a table?
I have tried to send <ns0:Rows>*</ns0:Rows> with no luck.
ChallanI'm not expert in Biztalk but one of the options to call stored procedure that contains the delete script:
http://geekswithblogs.net/StuartBrierley/archive/2011/10/19/biztalk-server-2010---using-the-wcf-sql-adapter-to-make.aspx
Sql Delete all rows from table Script:
DELETE FROM table_name;
or
TRUNCATE TABLE mytable;
Trucnate vs Delete:
http://www.mssqltips.com/sqlservertip/1080/deleting-data-in-sql-server-with-truncate-vs-delete-commands/
Fouad Roumieh -
Hi,
My requirement in OAF is to delete a row in a table if the row doesn't have mapping to another table.
If there is a mapping then the row must not be deleted.
I have created two VO and formed two ROW.
While using my code if there exists a mapping for a row in two tables, then the row doesnt get deleted.
But i want to DELETE when there exists no reference in second table.
The Code used in AM is
*public void deleteOU(String ReferenceId1) {*
OAViewObject VOB=getBLTARBOUMAPEOView1();
Row row=VOB.getCurrentRow();
Boolean flag=false;
*while(row!=null) {*
OAViewObject VOB1=getBLTINVMAPVO1();
Row row1=VOB1.first();
*while(row1!=null) {*
*if((row1.getAttribute("OuReffId").equals(ReferenceId1))){*
flag=true;
throw new OAException("Can't delete because Inventory is Assigned for this Operating Unit",OAException.ERROR);
*else{*
row1=VOB1.next();
*if(flag==false){*
System.out.println("Remove");
row.remove();
Ex:
Table1
ReferenceId OU
1 ABC
2 DEF
Table2
ReferenceId OUID
2 567
In the example my code must not allow to delete the 2nd ReferenceId in Table 1.
Please advice.
Thanks in Advance,
JeganHi,
I have modified the Query, now the row deletes the next row in the table.
For ex:
If i click 1st row second row is deleted.
*public void deleteOU(String ReferenceId1) {*
OAViewObject VOB=getBLTARBOUMAPEOView1();
Row row=VOB.getCurrentRow();
Boolean flag=false;
*while(row!=null) {*
System.out.println(ReferenceId1);
OAViewObject VOB1=getBLTINVMAPVO1();
Row row1=VOB1.first();
*while(row1!=null) {*
*if((row1.getAttribute("OuReffId").equals(ReferenceId1))){*
flag=true;
throw new OAException("Can't delete because Inventory is Assigned for this Operating Unit",OAException.ERROR);
*else{*
row1=VOB1.next();
*if(row1==null){*
row.remove();
*//getOADBTransaction().commit();*
throw new OAException("Deleted Successfully",OAException.CONFIRMATION);
Please help to solve this issue. -
Add / Delete a row in a table without using a button
Hi,
I was just wondering if it was possible to remove or add a row in a table without using the button? I noticed that in all examples, it always involve putting code in the button click event but I wanted to add or delete a row in a table based on the fact if the row contains a certain value or not. Is that possible?
Much appreciated,
VincentVincent,
Here is the updated file..
https://acrobat.com/#d=bVDBNM0pnS2IpfE58V01Tg
You have checked the checkbox "Repeat subform for each Row" for Header Row under IndTable1. You need to do at Row1 level of Table1.
I bound the Row1 of Table1 to <Row1> tag in your XML which can repeat multiple times.
I wrote the code in the Doc Ready event of the Test1 field to check whether the value is existing or not. If it does not have a value, then I am removing the instance of the Row1 by passing the current index.. (You can check the code)..
While creating a data connection using XML you need to make sure that the below structure is repeated atleast 2 times. And while previewing you can use make a copy of this same XML and remove Row1.
<Row1>
<Test1>Individual Name 1</Test1>
</Row1>
Thanks
Srini -
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 do i delete multiple rows in JTable
hello
how i delete multiple rows in JTable
when i selected multiple rows from the jtable and delete its give the error ArrayIndexOutOfBoundException
e.g.
int rows[]=jtable.getSelectedRows();
for(int i=0;i<rows.length;i++)
DefaultTableModel model=(DefaultTableModel)jtable.getModel();
model.removeRow(rows);
like this
please help me
merajYou are trying to remove the rows an equal times to the amount of rows selected.
You should remove one row at a time:
model.removeRow(rows);
Change your code into this.
for(int i=0;i<rows.length;i++)
DefaultTableModel model=(DefaultTableModel)jtable.getModel();
model.removeRow(rows[i]); -
Delete Multiple Rows of JTable by selecting JCheckboxes
Hi,
I want delete rows of JTable that i select through JCheckbox on clicking on JButton. The code that i am using is deleting one row at a time. I want to delete multiple rows at a time on clicking on Button.
This is the code i m using
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableTest extends JFrame implements ActionListener
JButton btnAdd;
BorderLayout layout;
DefaultTableModel model;
JTable table;JButton btexcluir;
public static void main(String[] args)
TableTest app = new TableTest();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public TableTest()
super("Table Example");
btnAdd = new JButton("Add");
btnAdd.addActionListener(this);
model = new DefaultTableModel()
public Class getColumnClass(int col)
switch (col)
case 1 :
return Boolean.class;
default :
return Object.class;
table = new JTable(model);
table.setPreferredSize(new Dimension(250,200));
// Create a couple of columns
model.addColumn("Col1");
model.addColumn("Col2");
JCheckBox cbox = new JCheckBox();
// Append a row
JPanel painel = new JPanel();
model.addRow(new Object[] { "v1",new Boolean(false)});
model.addRow(new Object[] { "v3", new Boolean(false)});
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.createVerticalScrollBar();
btexcluir= new JButton("Excluir");
btexcluir.addActionListener(this);
painel.add(btexcluir);
painel.add(btnAdd);
getContentPane().add(scrollPane, BorderLayout.NORTH);
getContentPane().add(painel, BorderLayout.SOUTH);
setSize(600, 600);
setVisible(true);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnAdd)
model.addRow(new Object[] { "Karl", new Boolean(false)});
if (e.getSource()==btexcluir){
for (int i=0; i <=model.getRowCount(); i++){
if (model.getValueAt(i,1)==Boolean.FALSE)
JOptionPane.showMessageDialog(null, "No lines to remove!!");
else if(model.getValueAt(i,1)==Boolean.TRUE)
model.removeRow(i);
}Please reply me with code help.
Thanks
NitinHi,
Thanks for ur support. My that problem is solved now. One more problem now . Initially i want that delete button disabled. When i select any checkbox that button should get enabled. how can i do that ?
Thanks
Nitin
Maybe you are looking for
-
What happens on my activation date?
Hi, I just switched broadband to BT from Sky, and would like to know what will happen on my activation date??? Does my Sky broadband just stop? Sorry for the newb question Solved! Go to Solution.
-
Trying to download the free trial of Adobe Acrobat XL Pro. I keep getting the message "The application could not be installed because the installer file is damaged. Try obtaining a new installer file from the application author." I've repeatedly tr
-
Using iMac as speaker phone for docked iphone
Maybe I am missing something "fundamental"... But if my iphone (3G) is docked with my iMac, can I use the iMac as a "speaker phone"? Any additional applications that do this? It would be nice to use the headset that I already have connected to my iMa
-
Why has my iPad1 stopped loading photos from my camera? I have 40G of free space.
Why has my iPad1 stopped loading photos from my camera? I have >40G of free space. It worked fine the first 3 times and then stopped. I also tried the SD card adapter and it doesn't recognize it either.
-
Evaluate function to convert presentation variable to date not working..
Hi, I have a calendar prompt on my dashboard and the presentation variable for this prompt is PV1. I am using this variable in my report to create a calculated column. The condition for the calc column runs something like case WHEN "Time"."Day" >= AN