This question is probably more suited for a Firebird forum, but I'll give it a try here anyway.
I have two tables.
COUNTRIES - Contains ISO Country Information (ISO3166-1)
STATES - Contains ISO Subdivision Level information (ISO3166-2
There is a foreign key relationship between the two tables on the ISO3 field. I have it set to Cascade updates to the states file in the unlikely event that the ISO3 code is changed. The cascade is working properly and all appropriate subdivision records are updated (Deletes are not allowed).
However I have another field called "dependancy", which is a similar relationship but instead refers to the country file itself for those "countries" that are dependencies of other countries (EG Puerto Rico or American Samoa for the US). To be complete, should the ISO3 field change the DEPENDANCY field should also change in all the dependent country rows.
How would you handle this? Yes, I could do it in my code, but it seems more appropriate to have a DB Trigger do it. I created the following trigger, but it does not seem to work. As far as I can tell it's not getting executed.
CREATE TRIGGER TR_COUNTRYISO3 FOR COUNTRIES ACTIVE
AFTER UPDATE POSITION 0
AS BEGIN
IF (NEW.ISO3 <> OLD.ISO3) THEN
BEGIN
UPDATE COUNTRIES SET DEPENDANCY = NEW.ISO3 WHERE DEPENDANCY = OLD.ISO3;
END
END;