Is there a way, when you have a list of entries, to check if each of these entries has foreign key references before trying to delete any of these entries?
As an example, if I have a list of borrowers and a list of books, you cannot delete a borrower from the system if he still has books on credit. (My actual system is much more complicated than this - many more tables.)
I would like to remove the delete option from any borrowers who have books on credit (in this example).
If I try to delete an entry using foreign key references, I get an error message:
Error accessing database: cannot delete or update parent line: foreign key constraint ends with an error ( dbname. tablename, CONSTRAINT fkfieldidFOREIGN KEY ( fieldid) LINKS tablename( fieldid))
One solution is to write a query to check whether each entry in the list of entries has any links to foreign keys in any of the possible tables that can be referenced.
However, if I want to display a list of 100 records from a table in my content management system, and I need to run 100 subqueries to display this list, this is clearly very inefficient!
End users get confused when they try to delete a record, but they cannot, because this data is “used” elsewhere, so I would rather remove the delete option to avoid confusion.
, ?
.