Intercept Foreign Keys violation via JDBC
mc1976Jul 30 2009 — edited Nov 20 2014Hi to all,
I'm trying to face the problem to ensure data integrity in my applications, expecially to ensure that in a DB table, in a column which refers to some entity's code (e.g, a customer code), there is no way to insert an illegal value. Of course, by defining Foreign Key Constraints, i'm able to achive this goal in a simply and reliable way.
The problem is I can't figure out how to get which was the illegal value user tried to insert. Until now, if I have to populate a table with n different codes, defined in n different
tables, I'm forced to verify via select which codes are legal and which not, and produce an error message. If the codes to be check are quite a number, this approach is really inefficient, so i'm trying another way.
Any suggestion ?
Thank you.