Subject BUG IN FIREBIRD
Author banzatto@ciagri.usp.br
i have a trigger before insert with code below :

if (EXISTS(SELECT A.DIVISAO1,A.DIVISAO2,A.DIVISAO3,A.DIVISAO4 FROM
AREA A WHERE
(A.DIVISAO1 = NEW.DIVISAO1) AND (A.DIVISAO2 =
NEW.DIVISAO2) AND
(A.DIVISAO3 = NEW.DIVISAO3) AND (A.DIVISAO4 =
NEW.DIVISAO4))) THEN
EXCEPTION CHAVE_DUPLICADA;

when it´s dispared the code is changed to

SELECT COUNT(*) FROM RDB$DATABASE WHERE (EXISTS(SELECT
A.DIVISAO1,A.DIVISAO2,A.DIVISAO3,A.DIVISAO4 FROM AREA A WHERE
(A.DIVISAO1 = 'A' ) AND (A.DIVISAO2 = 'A' ) AND
(A.DIVISAO3 = cast(null as char) ) AND (A.DIVISAO4 = cast(null
as char) )))

the fields with <null> are changed for cast(null as char) don´t
executing the exception

i analized this code with IB expert debug the trigger

what´s the problem ???