在我的Oracle数据库中我创建了这个触发器但是我遇到了问题,因为我正在使用定义了触发器的表。我怎么解决这个问题?
create or replace
trigger update_disabled
before update of is_disabled on passholder
for each row
declare
num number;
begin
if (:new.is_disabled='N' and :old.is_disabled='Y') then
select count (*) into num from ticket t,seat s where t.ref_passholder.id=:new.id and t.ref_seat=ref(s) and s.seat_type='disabled';
end if;
if num>0 then
raise_application_error( -20001, 'Care,for this person is already booked a seat reserved for a disabled. Before update,delete the ticket registered for this person.');
end if;
end;
/
我在尝试此错误时遇到此错误:
insert into seat values('14','10',500,'normal',(select * from(select ref(f) from fixture f order by dbms_random.value desc)where rownum=1));
insert into passholder values('11','Name','Surname',TO_DATE('25-08-1985','DD-MM-YYYY'),'N','NY');
insert into ticket values('10',(select ref(s) from seat s where s.id='14'),(select ref(p) from passholder p where p.id='11'),TO_DATE(sysdate+dbms_random.value(1,100),'dd-MM-yy hh24:mi:ss'));
update seat set seat_type='disabled' where seat_type='normal' and id='14';
我得到了错误:
ORA-04091,ORA-06512,第5行,ORA-04088。