1

我正在尝试通过在触发器下方写入对 wokson_staff 表执行一些约束,但出现以下错误:

PLS-00103:在预期以下之一时遇到符号“选择”:
(-+case mpd mew mot null............)

谁能帮我弄清楚我的触发器出了什么问题?

谢谢

Create or replace trigger Emp_cons
Before Insert on WorksON_Staff
For each row          
begin
where exists( SELECT worksON_staff.AssignmentNo, worksON_staff.StaffNo,
               staff.stafftype
                   FROM worksON_Staff,staff,workassignment
                  WHERE worksON.assignmentNo=worksON_staff.assignmentNo
                  and staff.staffNo=worksON_staff.staffNo
                  and
                  staff.stafftype ='supervisor'
                       INTERSECT 
                 SELECT worksON_staff.AssignmentNo,        worksON_staff.StaffNo,staff.stafftype
                   FROM worksON_Staff,staff,workassignment
                  WHERE
                  worksON.assignmentNo=worksON_staff.assignmentNo
                  and staff.staffNo=worksON_staff.staffNo
                  and
                  staff.stafftype ='authorizer') 
                  Then raise_error('71001', 'blahblablah');

end Emp_cons;
4

2 回答 2

1

你可以做这样的事情

    Create or replace trigger Emp_cons
    Before Insert on WorksON_Staff
    For each row
    declare  
    x number;            
    begin
    select count(*) into x from ( 
              SELECT :new.AssignmentNo,:new.StaffNo, staff.stafftype
              FROM staff,workassignment worksON
              WHERE worksON.assignmentNo=:new.assignmentNo
              and staff.staffNo=:new.staffNo
              and
              staff.stafftype ='supervisor'
                   INTERSECT 
              SELECT :new.AssignmentNo,:new.StaffNo,staff.stafftype
              FROM staff,workassignment worksON
              WHERE worksON.assignmentNo=:new.assignmentNo
              and staff.staffNo=:new.staffNo
              and
              staff.stafftype ='authorizer');

if (x>0) then
  --do your raise error procedure
end if;
于 2012-04-30T02:55:15.237 回答
0

从 where exists 开始,您的触发器在语法上是错误的

在此之前您是否缺少选择语句?

于 2012-04-30T02:03:29.380 回答