我有球员阵容的桌子。我想创建触发器,这将不允许插入超过11名球员在一排。
表有3列。Id,IdLineup,IdPlayer。
我的代码:
create or replace
trigger maximum_hracu before insert on sestava for each row
begin
if inserting then
if (select count(*) from hraje where hraje.id_sestava = :new.id_sestava) <= 11 then
insert into hraje values(seq_hraje.nextval,:new.id_sestava,1);
end if;
end if;
end;发布于 2015-06-07 21:36:48
在PL/SQL中,总是使用INTO子句赋值。
你可以尝试使用下面的(未测试的):
Begin
select count(*) INTO v_abc from hraje where hraje.id_sestava = :new.id_sestava
...
if (v_abc <= 11) Then
insert into hraje...
...https://stackoverflow.com/questions/30693898
复制相似问题