Subject Trigger with error handling
Author fb_cse
Hello,

I'm new in Firebird World and I've some problem with error handling
in trigger.

I've got this Oracle trigger and I want the same for Firebird. How
can I translate it :

CREATE OR REPLACE TRIGGER "ECOSYS".TAD_TR_KANTON
AFTER DELETE on TR_KANTON for each row

declare
numrows NUMBER;
err_no NUMBER;
err_msg VARCHAR2(255);
err_appl EXCEPTION;

begin

select count(*) into numrows
from TR_AMT
where
TR_AMT.AMT_KAN_ID = :old.KAN_ID;
if (numrows > 0)
then
err_no := -20004;
err_msg := '[TR_KANTON;KAN_ID;TR_AMT;AMT_KAN_ID]';
raise err_appl;
end if;

select count(*) into numrows
from TR_ORT
where
TR_ORT.ORT_KAN_ID = :old.KAN_ID;
if (numrows > 0)
then
err_no := -20004;
err_msg := '[TR_KANTON;KAN_ID;TR_ORT;ORT_KAN_ID]';
raise err_appl;
end if;

EXCEPTION
when err_appl then
raise_application_error(err_no, err_msg);
when OTHERS then
RAISE;

end;