Delete records from two tables
Hi All,
I have two tables (tableA and tableB) and i have four combination primary key.
How can I delete the records from tableA that are not in tableB?
In my sample below I need to delete the records from year 2013.
I have a loop to insert the new ones.
Thanks
Johnny
create table tableA(
keyA_id number,
keyB_id number,
keyC_id number,
keyD_id number,
amount number,
CONSTRAINT "PK_TABLEA" PRIMARY KEY (keyA_id, keyB_id, keyC_id, keyD_id)
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2011,10);
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2012,40);
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2013,20);
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2011,10);
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2012,30);
insert into tableA(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2013,20);
create table tableB(
keyA_id number,
keyB_id number,
keyC_id number,
keyD_id number,
amount number,
CONSTRAINT "PK_TABLEB" PRIMARY KEY (keyA_id, keyB_id, keyC_id, keyD_id)
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2011,10);
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2012,40);
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,1,2014,40);
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2011,10);
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2012,30);
insert into tableB(keyA_id,keyB_id,keyC_id,keyD_id,amount)
values(1,1,2,2014,30);
r you trying to do something like below ?
Delete from TableA A
where not exists (select 1 from TableB B where
A.keyA_id=B.keyA_id and
A.keyB_id=B.keyB_id and
A.keyC_id=B.keyC_id and
A.keyD_id=B.keyD_id)
Similar Messages
-
Delete records from internal table
hi all,
i want to delete records from intenal table which are starting with a particular starting number .
eg internal table
10000
20000
90000
91000
92000
88880
i want delete the records starting with 9 i.e. 90000 91000 92000.
Thanks in Adv
RAJYou can test this piece of code.
DATA:
i_tab TYPE STANDARD TABLE OF mara,
wa_tab TYPE mara.
wa_tab-matnr = '1000'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1002'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '1003'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '2001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '3001'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
wa_tab-matnr = '4010'.
APPEND wa_tab TO i_tab.
CLEAR wa_tab.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM -
Delete records from multiple table
Hi,
I need to delete records from multiple tables using a single delete statement. Is it possible ? If so please let me know the procedure.
Kindly Help.
Thanks,
Alexander.Hi Tim,
Syntax of DELETE statement does not allow for multiple tables to be specified in this way. Infact, none of the DMLs allow you to specify table names like this.
Technically, there are other ways of deleting from multiple tables with one statement.
1. "Use a trigger":
What was probably meant by this is that you have a driving-table on which you create a on-delete trigger. In this trigger, you write the logic for deleting from other tables that you want to delete from.
This does mean a one-time effort of writing the trigger. But the actual DML operation of deleting from all the tables would be simply triggered by a delete on driving-table.
2. Dynamic SQL:
Write a PL/SQL code to open a cursor with table-names from which you want the data to be deleted from. In the cursor-for loop, write a dynamic SQL using the table-name to delete from that table.
3. Using Foreign-Key constraint with Cascade-Delete:
This I feel is a more 'cleaner' way of doing this.
Having to delete data from multiple tables means that there is some kind of parent-child relationship between your tables. These relationships can be implemented in database using foreign-key constraints. While creating foreign-key constraint give the 'on delete cascade' clause to ensure that whenever data is deleted from parent-table, its dependent data is deleted from child-table.
Using foreign-key constraint you can create a heirarchy of parent-child relationships and still your DELETE would be simple as you would only have to delete from parent-table.
IMPORTANT: Implementing foreign-key constraints would also impact other DML operations that you should keep in mind. -
The data is migrated to our production database by accident and I would like to delete those records by using the created date and created by. this information is exits in two tables and I am wondering what i need to do to
delete the records from both tables. refvendor is the main table. please help.
SELECT *
FROM refvendor v, refvendoraddress a
WHERE v.refvendor_id = a.refvendor_id
AND v.createdby = 'Migration'
AND TRUNC (v.created_dt) = TO_DATE ('5/4/2010', 'MM/DD/YYYY')You can set the foreign key on: on delete cascade;
example:
SQL> create table refvendor (refvendor_id number);
Table created.
SQL> alter table refvendor add primary key (refvendor_id);
Table altered.
SQL> create table refvendoraddress (refvendor_id number);
Table created.
SQL> alter table refvendoraddress add constraint refvendoraddress_r01 foreign key (refvendor_id)
2 references refvendor (refvendor_id) on delete cascade;
Table altered.
SQL> insert into refvendor values (1);
1 row created.
SQL> insert into refvendor values (2);
1 row created.
SQL> insert into refvendor values (3);
1 row created.
SQL> insert into refvendor values (4);
1 row created.
SQL> insert into refvendor values (5);
1 row created.
SQL> insert into refvendoraddress values (1);
1 row created.
SQL> insert into refvendoraddress values (2);
1 row created.
SQL> insert into refvendoraddress values (3);
1 row created.
SQL> insert into refvendoraddress values (4);
1 row created.
SQL> insert into refvendoraddress values (5);
1 row created.
SQL> delete from refvendor where refvendor_id > 3;
2 rows deleted.
SQL> select count(*) from refvendor;
COUNT(*)
3
SQL> select count(*) from refvendoraddress;
COUNT(*)
3 L. -
How to delete records from MTL_SYSTEM_ITEMS table
Hello Experts,
BANNER
=======
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
I am working on Oracle Apps - 11.5.8 version.
I have some doubts in deleting the records from MTL_SYSTEM_ITEMS table.
There are few records which have junk characters and currently resides in table.
I need to delete those records.
But as per the approach; we should not delete any data directly from MTL table as it would cause huge impact.
I have followed the below approach; but didnt worked out well.
Script
=======
1)
I have modified the below parameter in the MTL_SYSTEM_ITEMS_INTERFACE table --> SET_PROCESS_ID =0,TRANSACTION_TYPE ='DELETE',PROCESS_FLAG=1 .
Apart from that; everything remains the same as in MTL_SYSTEM_ITEM table.
2) Called the "Import Items" concurrent program.
It got successfully completed. But record still exists in MTL_SYSTEM_ITEMS_INTERFACE table
Your help is highly appreciated.
Insert into MTL_SYSTEM_ITEMS_INTERFACE
(SET_PROCESS_ID ,TRANSACTION_TYPE,PROCESS_FLAG ,INVENTORY_ITEM_ID, ORGANIZATION_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN,
SUMMARY_FLAG, ENABLED_FLAG, DESCRIPTION, BUYER_ID, SEGMENT1, ATTRIBUTE3, ATTRIBUTE4, ATTRIBUTE9, ATTRIBUTE15, PURCHASING_ITEM_FLAG, SHIPPABLE_ITEM_FLAG,
CUSTOMER_ORDER_FLAG, INTERNAL_ORDER_FLAG, SERVICE_ITEM_FLAG, INVENTORY_ITEM_FLAG, ENG_ITEM_FLAG, INVENTORY_ASSET_FLAG, PURCHASING_ENABLED_FLAG,
CUSTOMER_ORDER_ENABLED_FLAG, INTERNAL_ORDER_ENABLED_FLAG, SO_TRANSACTIONS_FLAG, MTL_TRANSACTIONS_ENABLED_FLAG, STOCK_ENABLED_FLAG, BOM_ENABLED_FLAG, BUILD_IN_WIP_FLAG,
REVISION_QTY_CONTROL_CODE, CATALOG_STATUS_FLAG, RETURNABLE_FLAG, TAXABLE_FLAG, QTY_RCV_EXCEPTION_CODE, ALLOW_ITEM_DESC_UPDATE_FLAG, RECEIPT_REQUIRED_FLAG,
RFQ_REQUIRED_FLAG, QTY_RCV_TOLERANCE, LIST_PRICE_PER_UNIT, PRICE_TOLERANCE_PERCENT, ENFORCE_SHIP_TO_LOCATION_CODE, ALLOW_SUBSTITUTE_RECEIPTS_FLAG,
ALLOW_UNORDERED_RECEIPTS_FLAG, DAYS_EARLY_RECEIPT_ALLOWED, DAYS_LATE_RECEIPT_ALLOWED, RECEIPT_DAYS_EXCEPTION_CODE, RECEIVING_ROUTING_ID, LOT_CONTROL_CODE,
SHELF_LIFE_CODE, SHELF_LIFE_DAYS, SERIAL_NUMBER_CONTROL_CODE, RESTRICT_SUBINVENTORIES_CODE, RESTRICT_LOCATORS_CODE, LOCATION_CONTROL_CODE, ACCEPTABLE_EARLY_DAYS,
PLANNING_TIME_FENCE_CODE, LEAD_TIME_LOT_SIZE, ACCEPTABLE_RATE_INCREASE, ACCEPTABLE_RATE_DECREASE, PLANNING_TIME_FENCE_DAYS, END_ASSEMBLY_PEGGING_FLAG,
REPETITIVE_PLANNING_FLAG, BOM_ITEM_TYPE, PICK_COMPONENTS_FLAG, REPLENISH_TO_ORDER_FLAG, ATP_COMPONENTS_FLAG, ATP_FLAG, WIP_SUPPLY_TYPE, PRIMARY_UOM_CODE,
PRIMARY_UNIT_OF_MEASURE, ALLOWED_UNITS_LOOKUP_CODE, COST_OF_SALES_ACCOUNT, SALES_ACCOUNT, DEFAULT_INCLUDE_IN_ROLLUP_FLAG, INVENTORY_ITEM_STATUS_CODE,
INVENTORY_PLANNING_CODE, PLANNING_MAKE_BUY_CODE, FIXED_LOT_MULTIPLIER, ROUNDING_CONTROL_TYPE, CARRYING_COST, POSTPROCESSING_LEAD_TIME, PREPROCESSING_LEAD_TIME,
FULL_LEAD_TIME, MRP_SAFETY_STOCK_CODE, FIXED_DAYS_SUPPLY, RESERVABLE_TYPE, VENDOR_WARRANTY_FLAG, SERVICEABLE_COMPONENT_FLAG, SERVICEABLE_PRODUCT_FLAG,
PREVENTIVE_MAINTENANCE_FLAG, PRORATE_SERVICE_FLAG, INVOICEABLE_ITEM_FLAG, INVOICE_ENABLED_FLAG, MUST_USE_APPROVED_VENDOR_FLAG, OUTSIDE_OPERATION_FLAG,
COSTING_ENABLED_FLAG, AUTO_CREATED_CONFIG_FLAG, CYCLE_COUNT_ENABLED_FLAG, ITEM_TYPE, SHIP_MODEL_COMPLETE_FLAG, MRP_PLANNING_CODE, RETURN_INSPECTION_REQUIREMENT,
EFFECTIVITY_CONTROL, CHECK_SHORTAGES_FLAG, EQUIPMENT_TYPE, WEB_STATUS, BULK_PICKED_FLAG, LOT_STATUS_ENABLED, SERIAL_STATUS_ENABLED, LOT_SPLIT_ENABLED,
LOT_MERGE_ENABLED, DUAL_UOM_CONTROL, SERV_BILLING_ENABLED_FLAG, LOT_TRANSLATE_ENABLED, DEFAULT_SO_SOURCE_TYPE, CREATE_SUPPLY_FLAG)
Values
(0,'DELETE',1,464852, 102, TO_DATE('01/11/2007 16:15:11', 'MM/DD/YYYY HH24:MI:SS'), 3443, TO_DATE('08/24/2006 14:13:03', 'MM/DD/YYYY HH24:MI:SS'), 3443, 21069398,
'N', 'Y', 'pentaseal 6 X 320 SL-807202 Klockner', 4223, '0006320161', 'No', 'No', 'MRPM', 'N', 'Y', 'N', 'N', 'N', 'N', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y',
'Y', 'Y', 1, 'N', 'Y', 'N', 'WARNING', 'Y', 'Y', 'N', 3, 0, 20, 'WARNING', 'Y', 'Y', 5, 5, 'WARNING', 3, 1, 2, 1825, 1, 2, 2, 2, 10, 4, 1, 0, 0, 1, 'B', 'N', 4, 'N',
'N', 'N', 'N', 2, 'EA', 'EACH', 3, 12916, 14296, 'Y', 'Uncosted', 6, 1, 100, 1, 2, 0, 5, 50, 1, 20, 1, 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', 'N', 'Y',
'CMPC', 'N', 3, 2, 1, 'N', 2, 'UNPUBLISHED', 'N', 'N', 'N', 'N', 'N', 1, 'N', 'N', 'INTERNAL', 'Y');---------Hi,
You have to use the delete item utility of Oracle Inventory.
Responsibility: Inventory Superuser or similar
Navigation: Items -> Delete Items
Enter a meaningful name in the Group field.
Type - Item
Select the organization you want to delete the item from.
In the details section, enter the items you want to delete.
Once all the items entered, click on the "Chcek Group" button. This will validate whether the items you have entered are eligible to delete (i.e. whether any child record such as transactions exist).
It will submit a concurrent program and once the program finishes you will be able to see the result in the Results tab.
Finally click on the "Delete Group" button to delete the eligible items.
Thanks,
PS. -
Delete records from a Table. Please help
Hello Folks,
I have a table that contains 7 records with a Button to delete each record.
I am unable to delete any records from the table.
Please can some one just have a look into my class and tell me how
to delete a record from the table when the button is clicked.
You can also run this class from the your command Prompt
Just cut this and create a new java file.
Please assist.
Code Attached :
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class ButtonTableFactory {
public static JTable createTable(Vector data, String buttonLabel, ActionListener action) {
return createTable(data.iterator(), buttonLabel, action);
public static JTable createTable(
Iterator dataIterator,
String buttonLabel,
ActionListener action) {
DefaultTableModel model = new DefaultTableModel() {
public boolean isCellEditable(int row, int col) {
return col == 1;
model.setColumnCount(2);
while (dataIterator.hasNext()) {
Object[] row = { dataIterator.next().toString(), null };
model.addRow(row);
DefaultTableColumnModel columnModel = new DefaultTableColumnModel();
columnModel.addColumn(new TableColumn(0, 100));
columnModel.addColumn(new TableColumn(1, 80,
new TableButtonCellRenderer(buttonLabel),
new TableButtonCellEditor(buttonLabel, action)
JTable table = new JTable(model, columnModel) {
public void valueChanged(ListSelectionEvent e) {
super.valueChanged(e);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return table;
private static class TableButtonCellRenderer implements TableCellRenderer {
final JButton button;
TableButtonCellRenderer(String buttonLabel) {
button = new JButton(buttonLabel);
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus, int row, int column) {
return button;
private static class TableButtonCellEditor
extends AbstractCellEditor
implements TableCellEditor, ActionListener {
final JButton button;
final ActionListener callback;
TableButtonCellEditor(String buttonLabel, ActionListener callback) {
button = new JButton(buttonLabel);
this.callback = callback;
button.addActionListener(this);
public Component getTableCellEditorComponent(
JTable table,
Object value,
boolean isSelected,
int row, int column) {
return button;
public Object getCellEditorValue() {
return null;
public void actionPerformed(ActionEvent e) {
button.getParent().requestFocus();
callback.actionPerformed(e);
static JTable table;
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Vector items = new Vector();
for (int i = 0; i < 7; i++) {
items.add(Integer.toString(i));
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("You clicked row: " + table.getSelectedRow());
table = ButtonTableFactory.createTable(items, "More:", al);
frame.getContentPane().add(new JScrollPane(table));
frame.pack();
frame.show();This will get you closer:
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class ButtonTableFactory {
private JTable table;
private Vector items = new Vector();
private JScrollPane scroll;
private JPanel main;
private ActionListener al;
public static JTable createTable(Vector data, String buttonLabel, ActionListener action) {
return createTable(data.iterator(), buttonLabel, action);
public static JTable createTable(
Iterator dataIterator,
String buttonLabel,
ActionListener action) {
DefaultTableModel model = new DefaultTableModel() {
public boolean isCellEditable(int row, int col) {
return col == 1;
model.setColumnCount(2);
while (dataIterator.hasNext()) {
Object[] row = { dataIterator.next().toString(), null };
model.addRow(row);
DefaultTableColumnModel columnModel = new DefaultTableColumnModel();
columnModel.addColumn(new TableColumn(0, 100));
columnModel.addColumn(new TableColumn(1, 80,
new TableButtonCellRenderer(buttonLabel),
new TableButtonCellEditor(buttonLabel, action)
JTable table = new JTable(model, columnModel) {
public void valueChanged(ListSelectionEvent e) {
super.valueChanged(e);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return table;
private static class TableButtonCellRenderer implements TableCellRenderer {
final JButton button;
TableButtonCellRenderer(String buttonLabel) {
button = new JButton(buttonLabel);
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus, int row, int column) {
return button;
private static class TableButtonCellEditor
extends AbstractCellEditor
implements TableCellEditor, ActionListener {
final JButton button;
final ActionListener callback;
TableButtonCellEditor(String buttonLabel, ActionListener callback) {
button = new JButton(buttonLabel);
this.callback = callback;
button.addActionListener(this);
public Component getTableCellEditorComponent(
JTable table,
Object value,
boolean isSelected,
int row, int column) {
return button;
public Object getCellEditorValue() {
return null;
public void actionPerformed(ActionEvent e) {
button.getParent().requestFocus();
callback.actionPerformed(e);
public void init() {
main = new JPanel();
main.setLayout(new BorderLayout());
for (int i = 0; i < 7; i++) {
items.add(Integer.toString(i));
al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("You clicked row: " + table.getSelectedRow());
items.remove(table.getSelectedRow());
buildTable(items);
buildTable(items);
public void buildTable(Vector items) {
table = ButtonTableFactory.createTable(items, "More:", al);
scroll = new JScrollPane(table);
main.removeAll();
main.add(scroll);
main.revalidate();
main.repaint();
public JPanel getContent() {
return main;
public static void main(String[] args) {
ButtonTableFactory factory = new ButtonTableFactory();
factory.init();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(factory.getContent());
frame.setSize(300, 300);
frame.setVisible(true);
// frame.pack();
// frame.show();
} -
Help with listing records from two tables
Hi: I have two tables joined by the first field. The field is primary key in first table. Need help listing records from both tables with each record one line/record.
create table EVENTS (
event_key varchar2(64) primary key,
event_description varchar2(64),
create_time int
create table EVENT_UPDATES (
event_key varchar2(64) NOT NULL ,
update_description varchar2(64),
update_time int
insert into EVENTS values('Event1', 'This is event1', 1);
insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
insert into EVENTS values('Event2', 'This is event2', 4);
insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);I want to print each record in EVENTS table as one line and corresponding records in EVENT_UPDATES as one line/record like this
Event1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event clearedTIA
Raviselect case weight
when 1 then event_key
end key,
time_val,
description
from (
select event_key,
create_time time_val,
event_description description,
1 weight
from events
union all
select event_key,
update_time,
update_description,
2 weight
from event_updates
order by event_key,
weight
KEY TIME_VAL DESCRIPTION
Event1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event cleared
6 rows selected.
SQL> SY. -
Maximum Open cursor Exceeded error when deleting records from a table
I have a strange problem.
I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
Please help.
Thanks,
RajRaji03 wrote:
There is no trigger defined for this table.
Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
An example of a table with many many others foreign key'd to it.
create table parent_of_everything
column1 number primary key
insert into parent_of_everything select level from dual connect by level <= 1000;
commit;
--create 1000 tables all with foreign keys to the parent_of_everything
begin
for i in 1 .. 1000
loop
execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
commit;
end loop;
end;
TUBBY_TUBBZ?delete parent_of_everything;
1000 rows deleted.
Elapsed: 00:02:53.03No problems were had (none were expected).
Cleanup script.
--remove the 1000 child tables
begin
for i in 1 .. 1000
loop
begin
execute immediate 'drop table child_' || i || ' purge';
exception when others
then
null;
end;
end loop;
end;
/ -
Deleting records from internal tabl
Hi All,
Here i need delete records from one internal table, from another internal table. both contains same field as name1, so here , i need to delete records from t_itab , the records which are existed in t_itab1.
first internal table t_itab contains
vinesh01
vinesh02
vinesh03
vinesh04
second internal table t_itab1 contains
vinesh01
vinesh02
here i need to delte t_itab1 entries from t_itab.
regards,
vinesh.Hi,
try this code.
first internal table t_itab contains
vinesh01
vinesh02
vinesh03
vinesh04
second internal table t_itab1 contains
vinesh01
vinesh02
loop at t_itab1.
loop at t_itab.
if t_itab-name1 = t_itab1-name1.
delete t_itab.
(OR)
delete itab where t_itab-name = t_itab1-name.
endif.
endloop.
endloop.
regards.
sriram. -
Deleting records from Z table via an ABAP
Hello hoping someone can help me
I am about to start writing an abap that will delete records from three seperate z tables that have been in there for over 18 months.
Hoping that someone can give me a shove in the right direction to start me off as never had to do anything like this before.
Iv had a search through the forum but cant seem to find what im after
ThanksHi,
The below statement will do the purpose.
DELETE zcustom FROM TABLE ITAB. -
Deleting Records from Referential Tables
Hi,
Can anyone help me in deleting records from tables in a hierarcial manner. For e.g C refers B and B refers A. I need to delete data from all three tables related to a where clause in A.I tried using User_constraints and User_cons_columns views. But i am not able to find a hierarchial delete statement.
VenkateshDid you look into the option of specifying ON DELETE CASCADE for your foreign key constraints. That way, if you delete a
row from the master table Oracle will automatically go and delete the child rows. Take a look at the following script.
Here, when I delete a row from table A for NUM = 1 the child rows from table B (WHERE num = 1) are automatically deleted.
drop table b
drop table a
create table a (num number, name varchar2(40))
create table b (num number, name varchar2(40))
alter table a add constraint pk_a primary key(num)
alter table b add constraint fk_b_num foreign key (num) references a(num) on delete cascade
insert into a values (1, 'Test#1')
insert into a values (2, 'Test#2')
insert into b values (1, 'Referes#1')
insert into b values (2, 'Referes#2')
select * from a
select * from b
delete from a where num = 1
select * from a
select * from b
Sridhar,
Thanks a lot for your help.My exact need was to delete records in 50 tables starting with the key table for a specific condition in the key table.
Assume table A has 100 records,B 200 records,C 150 records,D 400 records, etc
When i want to delete some records in table A, i will not be able to do that as child records exists in table B and this structure will carry on till that last table in my application. How do i delete those specific records
Venkatesh -
Any way to restore deleted record from VBAP table.
Hi Guru,
Is their any way to restore deleted record from vabp.
Back is taken but , All quality server back is taken, any way to restore only
deleted VBAP data from all Back.
Regards
DurgeshHi Sahu ji,
you will not be able to get those records.
Check this : If this issue is in Development than no need to worry.
If in quality and production , then usually a copy of the system is there , and this can help you.
Also , check is there any report that exports this data in some other form for backup.
Hope it help you. -
Delete records from internal table using another internal table
HI,
I have two internal tables itab1 and itab2 which have same records initially.Later some records of itab2 are deleted .Then i want to delete those records from itab1 also ie,those records not found in itab2 .Is there any method other than looping.
So that itab1 again becomes equal to itab2.
Thanks in advance.
Sowmya.Soumya,
Itab1 , Itab2 .
Before deleting the records from itab2 move those records to one more internal table itab3.
Now you have deleted records of itab2 in itab3.
SORT ITAB3,ITAB1 by your main key field.
LOOP AT itab3.
READ TABLE ITAB1 WITH KEY key field = itab3-
keyfield.
IF sy-subrc EQ 0.
DELETE itab1 where keyfield eq itab3-keyfield.
ENDIF.
ENDLOOP. -
Deleting records from compared tables...
Hi all,
I know there are a bunch of posts regarding this issue...but I don't see one that quite fits this scenario. I have two tables with the exact same structure...with key field matnr. I want to delete all of those records from table A where the material does NOT exist in table B. Is there a terse way to accomplish this?Suresh and Ravi,
you are real good contributors to this forum and i like that.
Not that you give a LOT of answers, your answers even porve quality.
BUT i have one thing. People asking questions here are sometimes not TOO used to the ABAP syntax and other concepts.
SAP noticed that themselves and made some concepts "obsolete", to get a code which is better to read. Especially for newbies.
And well HEADER LINES are obsolete by now.
People not beeing really used to ABAP will have really big Problems in reading things like:
Loop at itab.
endloop.
or even harder:
modify itab.
this shall not be critic in any way, but rather a suggestion on how you can help the better. Accoring to your number of posts thats what you actually want.
thx for convenience. -
Deleting records from a table with 12 million records
We need to delete some records on this table.
SQL> desc CDR_CLMS_ADMN.MDL_CLM_PMT_ENT_bak;
Name Null? Type
CLM_PMT_CHCK_NUM NOT NULL NUMBER(9)
CLM_PMT_CHCK_ACCT NOT NULL VARCHAR2(5)
CLM_PMT_PAYEE_POSTAL_EXT_CD VARCHAR2(4)
CLM_PMT_CHCK_AMT NUMBER(9,2)
CLM_PMT_CHCK_DT DATE
CLM_PMT_PAYEE_NAME VARCHAR2(30)
CLM_PMT_PAYEE_ADDR_LINE_1 VARCHAR2(30)
CLM_PMT_PAYEE_ADDR_LINE_2 VARCHAR2(30)
CLM_PMT_PAYEE_CITY VARCHAR2(19)
CLM_PMT_PAYEE_STATE_CD CHAR(2)
CLM_PMT_PAYEE_POSTAL_CD VARCHAR2(5)
CLM_PMT_SUM_CHCK_IND CHAR(1)
CLM_PMT_PAYEE_TYPE_CD CHAR(1)
CLM_PMT_CHCK_STTS_CD CHAR(2)
SYSTEM_INSERT_DT DATE
SYSTEM_UPDATE_DT
I only need to delete the records based on this condition
select * from CDR_CLMS_ADMN.MDL_CLM_PMT_ENT_bak
where CLM_PMT_CHCK_ACCT='00107' AND CLM_PMT_CHCK_NUM>=002196611 AND CLM_PMT_CHCK_NUM<=002197018;
Thsi table has 12 million records.
Please advise
Regards,
Narayanuser7202581 wrote:
We need to delete some records on this table.
SQL> desc CDR_CLMS_ADMN.MDL_CLM_PMT_ENT_bak;
Name Null? Type
CLM_PMT_CHCK_NUM NOT NULL NUMBER(9)
CLM_PMT_CHCK_ACCT NOT NULL VARCHAR2(5)
CLM_PMT_PAYEE_POSTAL_EXT_CD VARCHAR2(4)
CLM_PMT_CHCK_AMT NUMBER(9,2)
CLM_PMT_CHCK_DT DATE
CLM_PMT_PAYEE_NAME VARCHAR2(30)
CLM_PMT_PAYEE_ADDR_LINE_1 VARCHAR2(30)
CLM_PMT_PAYEE_ADDR_LINE_2 VARCHAR2(30)
CLM_PMT_PAYEE_CITY VARCHAR2(19)
CLM_PMT_PAYEE_STATE_CD CHAR(2)
CLM_PMT_PAYEE_POSTAL_CD VARCHAR2(5)
CLM_PMT_SUM_CHCK_IND CHAR(1)
CLM_PMT_PAYEE_TYPE_CD CHAR(1)
CLM_PMT_CHCK_STTS_CD CHAR(2)
SYSTEM_INSERT_DT DATE
SYSTEM_UPDATE_DT
I only need to delete the records based on this condition
select * from CDR_CLMS_ADMN.MDL_CLM_PMT_ENT_bak
where CLM_PMT_CHCK_ACCT='00107' AND CLM_PMT_CHCK_NUM>=002196611 AND CLM_PMT_CHCK_NUM<=002197018;
Thsi table has 12 million records.
Please advise
Regards,
NarayanDELETE from CDR_CLMS_ADMN.MDL_CLM_PMT_ENT_bak
where CLM_PMT_CHCK_ACCT='00107' AND CLM_PMT_CHCK_NUM>=002196611 AND CLM_PMT_CHCK_NUM<=002197018;
Maybe you are looking for
-
Hi, I am currently working in a new application with a cRIO system and I am having some issues when try to run a VI. My actuall configured hardware is as follow: -cRIO-9113 4 slot chassis In this chassis I have installed 3 NI 9514 servo interface mod
-
Apogee Duet Fire Wire Hard Drive FW800 Port
Hey everyone. I recently bought the Apogee Duet which is friggin awesome by the way. I am now in need of an external 7200 HD that I will be saving all of my recordings onto. I've heard that if I plug a FW800 Hard Drive into my MacBook Pro 09 edition,
-
I am fortunate that my sister gave me her G4 FW800 I use it for a musical recording program called ProTools. I got ProTools last year as well as OS X(10.4.10) updated and all. My Sony display is fuzzy now and has been going between fuzzy and normal s
-
I just updated to OS X 10.9 and I tried connecting to the internet and it said that the passwords wrong and it dident have a IP address I tried the diagnostics for wi-FI and restarting it but nothing's working please help me with this problem
-
My question? When did making art get so technical? Also, have the software engineers at Adobe finally begun to shed the Cheetos from their beards and then crown themselves as artists extraordinaire? Well good for them! Bad for me! No offense, but I'