架构:
Customer(cid, cname, caddress, cphone, balance)
Movie(mid, title, genre, year)
Branch(bid, bname, baddress)
Copy(copyid, mid, bid)
Rented(cid, copyid, outdate, returndate, cost)
在客户退回电影时编写用于更新数据库的语句,即更新租赁记录和减少客户记录中的贷方余额。假设第一天的租金为3美元,每增加一天为1美元。
触发我写道:
DELIMITER $$
CREATE TRIGGER update_returndate AFTER UPDATE ON rented
FOR EACH ROW
BEGIN
IF (new.returndate is not null)
THEN
UPDATE customer
SET balance = balance - (3 + (new.returndate - old.outdate))
where cid = new.cid;
END IF;
END$$
DELIMITER ;
报告错误:无 问题:无休止地运行