Create or alter on existing trigger Firebird 1.5.6

193 views Asked by At

I recently came across this problem: I created a trigger for the wrong table (deny deletions on the table PHI).

SET TERM ^ ;
CREATE OR ALTER TRIGGER PHI_BD0 FOR DHI
ACTIVE BEFORE DELETE POSITION 0
AS
begin
  exception delnotallowed;
end
^
SET TERM ; ^

I overlooked that the trigger was created on table DHI instead of PHI. So corrected the statement and ran it again what - usually - recreates the trigger and should correct the problem.

SET TERM ^ ;
CREATE OR ALTER TRIGGER PHI_BD0 FOR PHI
ACTIVE BEFORE DELETE POSITION 0
AS
begin
  exception delnotallowed;
end
^
SET TERM ; ^

The script executes successfully but - really weird - the old trigger is still in place. No trigger on PHI, old trigger still active on DHI.

If a change an other trigger the same way without changing the target table the changes are always accepted (as expected).

The only way to get around the problem above is to delete the trigger before running the script. Of course this is not a real problem but things like this scare me as I can not rely on an exception being fired if something goes wrong.

UPDATED: I edited the complete post, sorry for posting the incomplete note in the first place. I hacked it in and wanted to complete it later but accidently posted it prematurely. Sorry for that.

0

There are 0 answers