这个触发器有问题吗?它假设更新另一个数据库中的表的日期字段。任何人都可以帮我一把吗?感谢
DROP TRIGGER IF EXISTS depoisDeInserir_invoice;
DELIMITER $$
CREATE TRIGGER depoisDeInserir_invoice AFTER INSERT ON pag_invoice
FOR EACH ROW
BEGIN
DECLARE trial datetime;
SET trial = (select dataTrial
from networkcen_1.companyproductuser
where (CompanyKey = NEW.companyKey)
and (ProductKey = NEW.productKey)
and (UserKey = NEW.productKey));
IF (trial < CURDATE()) THEN
UPDATE networkcen_1.companyproductuser
SET dataVencimento = DATE_ADD(CURDATE(),INTERVAL NEW.dias DAY)
where (CompanyKey = NEW.companyKey)
and (ProductKey = NEW.productKey)
and (UserKey = NEW.productKey);
ELSE
UPDATE networkcen_1.companyproductuser
SET dataVencimento = DATE_ADD(trial,INTERVAL NEW.dias DAY)
where (CompanyKey = NEW.companyKey)
and (ProductKey = NEW.productKey)
and (UserKey = NEW.productKey);
END IF;
END;
$$
DELIMITER ;