首页 > 代码库 > 表单触发器
表单触发器
控制表体不能有重复行
ALTER TRIGGER [dbo].[seoutstock_Update] ON [dbo].[SEOutStock]
FOR insert,update
AS
DECLARE @FInterID int
DECLARE @FStatus int
DECLARE @count int
If UPDATE(FStatus)
BEGIN
SELECT @FInterID = FInterID
FROM INSERTED
select @count = count(*)
from
(select FItemID
from seoutstockEntry
where FInterID = @FInterID and FItemID in (select FItemID from t_ICItem where FBatchManager=0)
group by FItemID
having count(*)>1) as temp
if @count >0
begin
ROLLBACK TRAN
RAISERROR(‘单身有物料重复行!‘,16,1)
end
END
控制单据二级审核 反审
ALTER TRIGGER [dbo].[ICStockBill_update1]
ON [dbo].[ICStockBill]
FOR update
AS
SET NOCOUNT ON
if exists (select 1 from deleted where ftrantype =41 and FHeadSelfD0132=35360 and isnull(fcheckerid,0)<>0)
begin
if exists (select 1 from inserted where ftrantype =41 and FHeadSelfD0132=35360 and isnull(fcheckerid,0)=0)
begin
DECLARE @FStatus int
DECLARE @Finterid int
select @FStatus=fcheckerid,@Finterid=finterid from icstockbill
where finterid in (select finterid from inserted)
if isnull(@FStatus,0)=0
begin
ROLLBACK TRAN
RAISERROR(‘已经出库,无法反审单据,请冲红!‘,18,18)
end
end
end
表单触发器