Oracle
Oracle“表級觸發器中不允許新舊引用”
我有這張桌子
CREATE table Pharmacists ( PhFname varchar2(10), PhLname varchar2(10), Salary number(7), Nationality varchar2(10), Shift_Start varchar2(2), Shift_End varchar2(2), PhID number(7) primary key, Super_ID number(7) , bdate date, constraint super_fk foreign key (Super_ID) references Pharmacists (PhID) on delete cascade);
我試圖創建這個觸發器
create or replace trigger updShE after update of Shift_Start on Pharmacists begin update Pharmacists set Shift_End=to_number(:new.Shift_Start, '99') +8 where PhID = :New.PhID ; end;
但出現此錯誤
表級觸發器中不允許新的或舊的引用
為此,您需要在級別觸發器之前設置一行。
而且您不需要更新,只需分配新值:
create or replace trigger updshe **BEFORE** update of Shift_Start on Pharmacists **FOR EACH ROW** begin :new.shift_end := to_number(:new.Shift_Start, '99') + 8; end; /