Subject Re: [ib-support] Question about update - trigger
Author David Zvekic
wasith zaki wrote:
> What is the trigger code that will update PVI_ID in table TBADDRESS if
> PVI_ID in table CITY changed.
>
> I was try using this code but it doesn't seem to work. Thanks for your
> help
>
> CREATE TRIGGER T_TBCITY_UPVI_ID FOR TBCITY
> ACTIVE AFTER UPDATE POSITION 0
> AS
> begin
> IF (NEW.PVI_ID <> OLD.PVI_ID) THEN
> UPDATE TBADDRESS SET TBADDRESS.PVI_ID=NEW.PVI_ID where
> TBADDRESS.CIT_ID = NEW.CIT_ID;
> End
>
>
> TIA,
> Wasith
>


Under certain circumstances your code should or should not update table TBADDRESS.
Can you give specific examples of what update failed to cause an update in table TBADDRESS
and what rows in TBADDRESS you were expecting to have updated?

I've noticed that if either NEW.PV_ID or OLD.PV_ID is null, then the code should do nothing.
Also if NEW.CIT_ID<> OLD.CIT_ID, then the code may be updating a row you may not be expecting
it to update.

David Z