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

トリガーは、存在する場所から開始することで構文的に間違っています

その前にselectステートメントがありませんか??

于 2012-04-30T02:03:29.380 に答える