I'm trying to delete 1 record based on primary key from (3) tables.
Here is the statement that I'm using
DELETE FROM CUSTOMER
WHERE EXISTS
( SELECT MERCHANTNAME
FROM CREDITCARD
WHERE MERCHANTNAME = 'VISA');
Deleting record of a customer with a VISA from customer table.
Here is the error that I'm getting
ORA-02292: integrity constraint (PLATINUMAUTOGROUP.CDRIVERLICENSENUM_FK) violated - child record found
I'm guessing CDRIVERLICENSENUM
is the foreign key in the 3rd table that I have. How do I go about this? Is it possible to delete 1 record from 3 tables in 1 statement?
the three tables are
customer / customer_creditcard / creditcard
You need to delete the records in the foreing tables before deleting the record in the primary table.
But perhaps your delete command in the CUSTOMER table might be wrong, because if the EXISTS command return true, all records will be deleted from the CUSTOMER table. Check if this is the result you expect.