我必须创建一个触发器,该触发器在某个列(小时结束)中不允许多个空值。这是我写的触发器(我使用的是 Sybase):
ALTER TRIGGER "InsertIntoCardDetail" instead of insert on
DBA.CardDetail
referencing new as new_name
for each row
begin
declare @nullCount integer;
if(new_name.hourfinish is null) then
select COUNT(*) into @nullCount
from CardDetail
where hourfinish is null;
if(@nullCount > 0) then
raiserror 99999 'Cannot have Multiple Nulls'
else
insert into CardDetail( card,hourstart,hourfinish,"work",project,N)
values( new_name.card,new_name.hourstart,new_name.hourfinish,new_name."work",new_name.project,new_name.N)
end if
else
insert into CardDetail( card,hourstart,hourfinish,"work",project,N)
values( new_name.card,new_name.hourstart,new_name.hourfinish,new_name."work",new_name.project,new_name.N)
end if
end
触发器工作正常。我要问的是是否有执行插入的命令 - 可以替换那些长插入语句的命令。