CREATE OR REPLACE TRIGGER tri_sc
BEFORE INSERT OR UPDATE ON sc
FOR EACH ROW
DECLARE
nosnointableS EXCEPTION;
nocnointableC EXCEPTION;
I number:=0;
BEGIN
select count(*) into i from s where s.sid=:new.sid;
If I < 1 then
raise nosnointableS;
Else
null;
End if;
select count(*) into i from c where c.cid=:new.cid;
If I < 1 then
raise nocnointableC;
Else
null;
End if;
EXCEPTION
when nosnointableS then
dbms_output.put_line('这个学号不存在,不能插入或修改.');
when nocnointableC then
dbms_output.put_line('这个课程号不存在,不能插入或修改.');
End;
END;
/
哪里错了???
如果不加DECLARE还是错的?能说明白吗,作业,谢谢。