SQL> CREATE OR REPLACE TRIGGER check_sscore
2 BEFORE INSERT ON ssystem FOR EACH ROW
3 DECLARE
4 score_out_exception EXCEPTION;
5 BEGIN
6 IF(:new.Major1Score<60) OR (:new.Major2Score<60) OR (:new.Major3Score<60) OR (:new.TotalScore<6
0) THEN
7 INSERT INTO ssystem VALUES(:new.sid,:new.sname,:new.EnglishScore,:new.PoliticsScore,:new.Major
1Score,
8 :new.Major2Score,:new.Major3Score,:new.TotalScore,'F');
9
10 ELSEIF (:new.Major1Score>100) THEN
11 RAISE score_out_exception;
12
13 ELSE
14 INSERT INTO ssystem VALUES(:new.sid,:new.sname,:new.EnglishScore,:new.PoliticsScore,:new.Major1
Score,
15 :new.Major2Score,:new.Major3Score,:new.TotalScore,'T');
16
17 END IF;
18 EXCEPTION
19 WHEN score_out_exception THEN
20 dbms_put.out_line('err');
21 END;
22 /
警告: 创建的触发器带有编译错误。
SQL> show err;
TRIGGER CHECK_SSCORE 出现错误:
LINE/COL ERROR
-------- -----------------------------
8/31 PLS-00103: 出现符号 "THEN"在需要下列之一时:
:= . ( % ;
16/1 PLS-00103: 出现符号 "EXCEPTION"在需要下列之一时:
begin case declare
else elsif end exit for goto if loop mod null pragma raise
return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
怎么改?
------解决方案--------------------
elsif吧?
------解决方案--------------------
10 ELSEIF (:new.Major1Score>100) THEN
11 RAISE score_out_exception;
should be elsif