MySQL Community Server 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 ;