Oracle Magazine, July/August 2018
Database Developer OPEN SOURCE ORACLE MAGAZINE JULY AUGUST 2018 103 cur con cursor statement delete from cx_ people where id id cur execute statement id 1 con commit When I run this code in my Python session I see Traceback most recent call last File delete py line 25 in module cur execute statement id 1 cx_ Oracle IntegrityError ORA 02292 integrity constraint DD FK_ CX_ PETS_ OWNER violated child record found Before deleting the person you must handle the pets watch out for claws and teeth There are handling options depending on the database design If pets are not required to have an owner And if you want to delete only the person not the pets you can update the pets data and set the pet owner value to null If pets are required to have an owner You can delete the pets of the owner In either of the above scenarios you can update the data and set the pet owner to another person The delete is successful Bob is moving out of the area and his new apartment doesnt allow pets so hes giving his dogs to Kim Lets use that last option here Replace the Your code here line in delete py with the following code snippet and run delete py in your Python session
You must have JavaScript enabled to view digital editions.