我想插入触发之前禁用在插入表时INSERT触发器
create or replace trigger CHECK_FOR_MAX_ENTRANTS
before insert on application
declare
entrants_count number;
max_entrants number;
begin
select count(*) into entrants_count from application
where id_speciality = :new.id_speciality;
select max_students_number into max_entrants from speciality s
where s.id_speciality = :new.id_speciality;
IF entrants_count >= max_entrants THEN
**disable this insert**
end;
我怎样才能做到这一些条件为真之前?
这种方法的另一个问题是,两个并发事务可以插入“最后”一个允许的记录,因为他们看不到其他的记录呢。 – 2011-06-10 19:27:54
此方法的其他一些问题包括: – 2011-06-13 13:17:10
PS。我很快就点击了“添加评论”。我想说...这种方法的其他一些问题包括:a)如果max_entrants.max_students_number更新为更小的数字会怎样?如果超过max_students_number,应用程序中的相关行会发生什么? b)如果application.speciality更新会怎么样?这可能会导致计数超过相关的max_entrants.max_students_number。 – 2011-06-13 13:39:28