我正在尝试在oracle中创建一个简单的函数:
CREATE OR REPLACE FUNCTION upd_film()
RETURN trigger
IS
BEGIN
IF (old.title != new.title) or (old.description != new.description)
THEN
UPDATE film_text
SET title=new.title,
description=new.description,
film_id=new.film_id
WHERE film_id=old.film_id;
END IF;
RETURN NULL;
END;
/
并收到以下编译错误:
UPD_FILM
FUNCTION 1 1 19
PLS-00103: Encountered the symbol ")" when expecting one of the following:
<an identifier> <a double-quoted delimited-identifier>
非常感谢您的帮助!! 非常感谢 ! 汤妮雅
编辑:
我实际上将一个名为SAKILA的mysql数据库移植到oracle上,是的,我将从触发器调用此函数,如下所示:
CREATE TRIGGER upd_film AFTER UPDATE ON film FOR EACH ROW EXECUTE FUNCTION upd_film();
我相信oracle你可以通过只使用一个触发器来实现它,但我不知道PL / SQL,请帮我写一个触发器来做它 - 谢谢你。
答案 0 :(得分:3)
尝试:
CREATE OR REPLACE TRIGGER upd_film
AFTER UPDATE
ON film
FOR EACH ROW
BEGIN
IF (:old.title != :new.title) or (:old.description != :new.description)
THEN
UPDATE film_text
SET title=:new.title,
description=:new.description,
film_id=:new.film_id
WHERE film_id=:old.film_id;
END IF;
END;
/