我已经定义了此触发器:
--#SET TERMINATOR @
CREATE TRIGGER actualizarSaldoIngreso
BEFORE INSERT ON Ingreso
FOR EACH ROW MODE DB2SQL
BEGIN
UPDATE Cuenta SET Saldo = Saldo + NEW.Cantidad WHERE IBAN = NEW.Cuenta_IBAN;
END@
--#SET TERMINATOR ;
但是db2返回此错误。有什么解决办法吗?
"NEW.CANTIDAD" is not valid in the context where it is used.
答案 0 :(得分:3)
--#SET TERMINATOR @
CREATE TRIGGER actualizarSaldoIngreso
BEFORE INSERT ON Ingreso
REFERENCING NEW as N
FOR EACH ROW MODE DB2SQL
BEGIN
UPDATE Cuenta SET Saldo = Saldo + N.Cantidad WHERE IBAN = N.Cuenta_IBAN;
END@
--#SET TERMINATOR ;