Subject | RE: [ib-support] Question about update - trigger |
---|---|
Author | Thomas Steinmaurer |
Post date | 2003-04-11T07:58:54Z |
Wasith,
if either the new or the old value of PVI_ID is NULL. So, in
that case the update will simply not happen.
There is only way to "catch" a change in a column, namely with
IF (((OLD.PVI_ID IS NULL) AND (NEW.PVI_ID IS NOT NULL)) OR
((OLD.PVI_ID IS NOT NULL) AND (NEW.PVI_ID IS NULL)) OR
(OLD.PVI_ID <> NEW.PVI_ID)) THEN
UPDATE TBADDRESS ...
HTH,
Thomas Steinmaurer
http://www.iblogmanager.com
> What is the trigger code that will update PVI_ID in table TBADDRESS ifThe main problem is that (NEW.PVI_ID <> OLD.PVI_ID) will fail
> 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
if either the new or the old value of PVI_ID is NULL. So, in
that case the update will simply not happen.
There is only way to "catch" a change in a column, namely with
IF (((OLD.PVI_ID IS NULL) AND (NEW.PVI_ID IS NOT NULL)) OR
((OLD.PVI_ID IS NOT NULL) AND (NEW.PVI_ID IS NULL)) OR
(OLD.PVI_ID <> NEW.PVI_ID)) THEN
UPDATE TBADDRESS ...
HTH,
Thomas Steinmaurer
http://www.iblogmanager.com