Tags: attempt, database, exception, foreign, insert, integrity, invalid, key, mysql, oracle, sql, statement, thrown, update, violates, violation, whenever
Exception for foreign key violation
Is an exception thrown whenever an update (insert, whatever) statement violates the integrity of the DB when an attempt is made at using an invalid foreign key? If so which is it?
Leave a comment...
- 4 Comments
- http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/errors.htm#sthref1966#1; Sat, 23 Feb 2008 14:43:00 GMT
- Yes an exception is thrown but there is no predefined exception for this error:
ERROR at line 1:
ORA-02291: integrity constraint (TEST.SYS_C0010757) violated - parent key not
ORA-06512: at line 2
but you can define it your own with a PRAGMA clause:#2; Sat, 23 Feb 2008 14:44:00 GMT
insert into t2
when ex1 then
PL/SQL procedure successfully completed#3; Sat, 23 Feb 2008 14:45:00 GMT
- Thank you all for your replies! You've helped me a great deal.#4; Sat, 23 Feb 2008 14:46:00 GMT