Oracle警告:执行完成并发出警告

时间:2012-04-30 01:58:26

标签: sql oracle triggers

我正在尝试在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;

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分:0)

从一开始,你的触发器在语法上是错误的 存在的地方

你错过了一个select语句吗?