我想编写一个SQL触发器,根据价格图表更改插入数据库的每部新电影的rental_rate。
当我按下ENTER时,命令行转到下一行而不是结束语句。 注意:问题1和2使用相同的代码。
CREATE TRIGGER trig_rental_rate
ON film
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO film
SELECT *,
CASE
WHEN (special_features = ‘Trailers’)
THEN rental_rate := rental_rate + 0.10;
WHEN (special_features = ‘Commentaries’)
THEN rental_rate := rental_rate + 0.50;
WHEN (special_features = ‘Deleted Scenes’)
THEN rental_rate := rental_rate + 0.20;
WHEN (special_features = ‘Behind the Scenes’)
THEN rental_rate := rental_rate + 0.20;
END
FROM
Inserted
END
答案 0 :(得分:0)
结束后按回车键。现在按'/'并按Enter键。您的代码现在将被编译。