I have one table ROUTE_DETAILS with column ROUTE_NUMBER and ROUTE_NAME. sql
I have another table CUSTOMER_DETAILS with column CUST_CODE, CUST_NAME, ROUTE_NUMBER. Here route number is the foreign key of ROUTE_DETAILS. app
ROUTE_DETAILS is parent table and CUSTOMER_DETAILS is child table. spa
Data in ROUTE_DETAILS: code
ROUTE_NUMBER ROUTE_NAME RN0001 ROUTE1 RN0002 ROUTE2 RN ROUTE3
Data in CUSTOMER_DETAILS: ci
CUST_CODE CUST_NAME ROUTE_NUMBER CC0001 CUSTOMER1 RN0001 CC0002 CUSTOMER2 RN
Now the problem is when I am trying to update ROUTE_NUMBER from ROUTE_DETAILS or update ROUTE_NUMBER from CUSTOMER_DETAILS an error is shown: integrity constraints violation child record found it
Query is: io
update ROUTE_DETAILS set ROUTE_NUMBER = 'RN0003' where ROUTE_NUMBER = 'RN'
same thing happen when I am trying to update customer_details. table
Yes, you cannot update the parent primary key if a child is referencing that key value. class
Also you cannot update the child to have a foreign key value that does not reference a primary key value in the parent table. date
So, you can either:
1)Relax the constraint temporarily while you make your changes, being sure to re-apply it afterwards.
Or
2)Delete the child row, update the parent row, then re-insert the child with the new foreign key value.