Subject Re: [firebird-support] Insert Trigger which makes an Update if pk allready there possible?
Author Helen Borrie
At 02:01 PM 20/08/2004 +0200, you wrote:
>Is it possible to write an Insert Trigger that test for the existence of
>the pk and then make an Update of the data if it allready exist?

No, a trigger acts as part of a specific operation (I/U/D) so a trigger
can't change the operation to be "insert" if it was "update" or to "update"
if it was "insert". All you could do here would be to have a routine to
create a different value for the PK and thus prevent the key
violation; but this isn't what you want here.

>Or must I use a Stored Procedure?

Yes, you can achieve this very elegantly with a stored procedure