我有电影行政桌
电影执行官与列
我想创建一个计算平均净值的触发器,如果它超过某个数量,比如 400000,则应该无法进一步插入,并且应该显示一条错误消息。(名称 varchar2(20),地址 varchar2(20),cert# number(10),networth float)
我实现了以下代码:
CREATE OR REPLACE TRIGGER pronet
AFTER INSERT
ON movieexec
FOR EACH ROW
DECLARE netavg float;
BEGIN
SELECT AVG(networth) INTO netavg FROM movieexec;
IF(netavg>400000) THEN
RAISE_APPLICATION_ERROR(-20000,'average limit reached, cannot insert');
ENDIF;
END
但是出现以下错误
ERROR at line 7: PLS-00103: Encountered the symbol ";" when expecting one of the following:
if
5. DECLARE netavg float;
6. BEGIN
7. **SELECT AVG(networth) INTO netavg FROM movieexec;**
8. IF(netavg>400000) THEN
9. RAISE_APPLICATION_ERROR(-20000,'average limit reached, cannot insert');
请协助。