Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

delete rows where the reference is not exists in parent table

mist123Oct 7 2021 — edited Oct 7 2021

Hi All,
Oracle 11.2

create table xxc_parent_tmp
as
select  '222_P' parent_inv from dual
union all
select '333_P' parent_inv from dual

I want to delete credit memo rows from xxc_credit_tmp where the parent_inv is not null and if not exists in xxc_parent_tmp table.
and except where the parent invoices are NULL in xxc_credit_tmp .

Example: 111_CM Credit_inv has 2 parent_inv records 111_P parent_inv is not exists in xxc_parent_tmp table.
So i want to delete row where the  parent_inv is '111_P' since it is not exists in xxc_parent_tmp table.
and so on....

create table xxc_credit_tmp
as
select '111_CM' Credit_inv, '111_P' parent_inv from dual
union all
select '111_CM' Credit_inv, '222_P' parent_inv from dual
union all
select '222_CM' Credit_inv, '333_P' parent_inv from dual
union all
select '333_CM' Credit_inv, '444_P' parent_inv from dual
union all
select '444_CM' Credit_inv, NULL parent_inv from dual
This post has been answered by Paulzip on Oct 7 2021
Jump to Answer
Comments
Post Details
Added on Oct 7 2021
5 comments
1,394 views