Hopefully someone can help me.
I need to delete some data from a table by referencing 2 other table.
Table A is the table I need to delete rows from but does not have all the data I need to determine if I need to delete the row. I have created a view that will give me all the columns from Table A and a column from Table B.
Table C Is the table the will determine on whether or not I will delete data from Table A. Below is the delete function that I ran. When I run the sql statement it show that 4 rows are deleted but the rows do not delete. Below is the sql statement. The vw_aphldinv_final is the view that I created. Thanks in advance!
Delete from aphldinv
Where exists
(select *
from vw_aphldinv_final
where aphldinv.vendor_group = vw_aphldinv_final.vendor_group
and aphldinv.hld_code = vw_aphldinv_final.hld_code
and aphldinv.company = vw_aphldinv_final.company
and aphldinv.vendor = vw_aphldinv_final.vendor
and aphldinv.invoice = vw_aphldinv_final.invoice
and aphldinv.suffix = vw_aphldinv_final.suffix
and aphldinv.cancel_seq = vw_aphldinv_final.cancel_seq
and aphldinv.seq_nbr = vw_aphldinv_final.seq_nbr
and aphldinv.void_seq = vw_aphldinv_final.void_seq)
I need to delete some data from a table by referencing 2 other table.
Table A is the table I need to delete rows from but does not have all the data I need to determine if I need to delete the row. I have created a view that will give me all the columns from Table A and a column from Table B.
Table C Is the table the will determine on whether or not I will delete data from Table A. Below is the delete function that I ran. When I run the sql statement it show that 4 rows are deleted but the rows do not delete. Below is the sql statement. The vw_aphldinv_final is the view that I created. Thanks in advance!
Delete from aphldinv
Where exists
(select *
from vw_aphldinv_final
where aphldinv.vendor_group = vw_aphldinv_final.vendor_group
and aphldinv.hld_code = vw_aphldinv_final.hld_code
and aphldinv.company = vw_aphldinv_final.company
and aphldinv.vendor = vw_aphldinv_final.vendor
and aphldinv.invoice = vw_aphldinv_final.invoice
and aphldinv.suffix = vw_aphldinv_final.suffix
and aphldinv.cancel_seq = vw_aphldinv_final.cancel_seq
and aphldinv.seq_nbr = vw_aphldinv_final.seq_nbr
and aphldinv.void_seq = vw_aphldinv_final.void_seq)