oracle的触发器问题

[复制链接]
查看11 | 回复2 | 2009-1-4 22:46:04 | 显示全部楼层 |阅读模式
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还是错的?能说明白吗,作业,谢谢。

回复

使用道具 举报

千问 | 2009-1-4 22:46:04 | 显示全部楼层
DECLARE nosnointableS EXCEPTION; nocnointableC EXCEPTION; I number:=0; declare在这里用?你好好看看基础的东西吧。。。...
回复

使用道具 举报

千问 | 2009-1-4 22:46:04 | 显示全部楼层
把报的错误信息贴上来看看吧...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行