我在MySQL社區服務器5.5.16中創建了一個更新觸發器,但是當我嘗試更新語句時:Update Account set credit = 100 Where Number = 14001455;
我收到一個錯誤「ERROR 1172(42000):結果包含多個行」。我不明白爲什麼我得到這個錯誤的,什麼是錯我的代碼:MYSQL觸發器更新不能正常工作
delimiter |
CREATE TRIGGER t_creditexceed AFTER UPDATE ON Account
FOR EACH ROW
BEGIN
DECLARE n_overdraft INTEGER;
DECLARE n_balance INTEGER;
DECLARE n_number INTEGER;
DECLARE n_credit INTEGER;
DECLARE credit_exception condition for SQLSTATE '07030';
SELECT balance, credit, number INTO n_balance, n_credit, n_number
FROM Account;
IF ((n_balance < (-n_credit)) AND (n_balance >= 1.1 * (-n_credit)))
THEN
SET n_overdraft = n_balance + n_credit;
INSERT INTO overdraft (account_no, over_draft) VALUES (n_number, n_overdraft);
END IF;
IF (n_balance < 1.1 *(- n_credit))
THEN signal credit_exception;
END IF;
END;
|
delimiter ;