0
Answer

Can I catch exception while deleting Parent Records? Is it Simple?

Ask a question
Ishwar Patel

Ishwar Patel

14y
2.2k
1
I have four tables one parent and three child's. From my application in one form, I want to delete Parent record. As you all know, I can not delete parent record if it is present in any child table.

While I delete parent record, I would like to know whether that record is present in any child table or not? If not present I want to delete that record.

How can I know the record is present in child tables (without actually quering into child tables)?
How can I use SQL exception raised for trying to delete parent record which is present in child tables?

Finally I do not want to let the users delete the parent record without actually going & checking into child tables.

Suggest me most efficient way. The above is just part of my application. Actually there are more than 25 child tables. It will be troublesome to actually check into each and every child table.