Subject Trapping Foreign Key violations in SQL
Author Tim Ledgerwood

I have a table in a database which has multiple foreign keys. When a key
violation happens, I would like to pass the user a message from the SQL
telling him which foreign key violation has occurred.

In other words, I have foreign key constraints on Tax_Type, Account_Type
and Account_Number. How would I identify exactly which one(s) of these have
been violated so that I can pass a more accurate message back to the user
from the database?

How would I do this in an insert procedure in SQL?

Thanks in advance


[Non-text portions of this message have been removed]