Subject Re: Stopping indexes see through Transactions?
Author Svein Erling
--- In firebird-support@yahoogroups.com, "johnsparrowuk" wrote:
> before insert trigger:
> select count(*) from mytable where pk = :new.pk into :a;
> if (a > 0) then
> exception key_viol;

Since PKs are unique this should be good enough, but

if exists(select * from mytable where pk = :new.pk) then
exception key_viol;

works OK even if there are lots of duplicates.

Set