我正在将一些旧的旧版Interbase数据库转换为MySql,我在转换触发器时遇到了一些麻烦。这是我到目前为止所看到的,但似乎无法理解以下触发器中的错误。你能帮忙解决一下语法吗?
DELIMITER ^
在这2个案例中,它说into new.FinancialCode
不正确。完成此任务的正确形式是什么? (在表格中查找值并在更新的行中更改)
Create Trigger triggerFinancialCode BEFORE UPDATE ON FLOW
FOR EACH ROW
begin
Select FinancialCode FROM Accounts where AccountCode = new.AccountCode
into new.FinancialCode ;
end ^
Create Trigger triggerFinancialCodePredicted BEFORE UPDATE ON PREDICTED_FLOW
FOR EACH ROW
begin
Select FinancialCode FROM Accounts where AccountCode = new.AccountCode
into new.FinancialCode ;
end ^
答案 0 :(得分:2)
试试这段代码 -
CREATE TRIGGER triggerFinancialCode BEFORE UPDATE ON FLOW
FOR EACH ROW
BEGIN
SET @var = NULL;
SELECT FinancialCode INTO @var FROM Accounts WHERE AccountCode = NEW.AccountCode;
SET NEW.FinancialCode = @var;
END
为第二次触发做同样的事。