我已经尝试了超过2个小时来获得此触发器的语法,但它一直给我编译错误,有人可以指出我的方向,我出错吗?
[Compilation errors: missing equal sign line 5, sql statement ignored, line 4]
film_actor包含以下字段:
actor_id
film_id
电影有以下几个字段:
film_id
rental_rate
CREATE OR REPLACE TRIGGER TRIGGER_ACTOR_STARRED
BEFORE INSERT ON film_actor FOR EACH ROW
BEGIN
IF :new.actor_id IN (SELECT *
FROM V_ACTORS_STARRED) THEN
UPDATE film
SET rental_rate := rental_rate * 1.10
WHERE :new.actor_id = film_actor.actor_id
AND film.film_id = film_actor.film_id;
END IF;
END;
/
我试图选择的视图如下:
CREATE OR REPLACE VIEW V_ACTORS_STARRED AS
SELECT actor_id
FROM actor
WHERE actor_id IN
(SELECT actor_id
FROM film_actor
WHERE film_actor.actor_id = actor.actor_id
AND film_id IN
(SELECT film.film_id
FROM film, film_category, category
WHERE category.name = 'Documentary'
AND film.film_id = film_category.film_id
AND film_category.category_id = category.category_id
AND rental_rate = (SELECT MAX(rental_rate)
FROM film, category, film_category
WHERE category.name = 'Documentary'
AND film.film_id = film_category.film_id
AND film_category.category_id = category.category_id)));
答案 0 :(得分:2)
您正在执行SQL更新 - 它应该使用常规=
SQL运算符,而不是pl / SQL的:=
赋值运算符:
UPDATE film
SET rental_rate = rental_rate * 1.10 -- Note ":=" was replaced with "="
WHERE :new.actor_id = film_actor.actor_id
AND film.film_id = film_actor.film_id;
答案 1 :(得分:1)
删除UPDATE语句的SET部分中的冒号。
UPDATE film
SET rental_rate = rental_rate * 1.10
WHERE :new.actor_id = film_actor.actor_id
AND film.film_id = film_actor.film_id;