Subject Re: [firebird-support] Detecting which FK has been violated within a SP
Author Helen Borrie
At 03:16 PM 15/02/2006, you wrote:
>Hi Group,
>
>Simple question that I cant think of the answer. I have a stored
>procedure that does a simple insert
>
>insert into mytable (a,b,c) values (1,2,3);
>
>I want to catch foreign key violations in a when ... do block. But I
>need to know which of the foreign keys has been violated. Is there a
>way to do this?

There won't be a magic context variable. :-)

But, in your handler, you can query the primary tables in the same
order of battle to find which key is missing, with the objective of
then raising a custom exception identifying the offending key,
logging out to an external table, or whatever.

./hb