触发器

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

 

 


ALTER       trigger SalesOrderD_T_Checking on dbo.SalesOrderD
for insert , update
as
declare @a int

if exists(select * from inserted
inner join SalesOrderH on inserted.ReceiptCode = SalesOrderH.ReceiptCode
where not exists(select * from CustProd
where CustProd.CustomerCode = SalesOrderH.CustomerCode 
and CustProd.CustomerType = SalesOrderH.CustomerType
and CustProd.TradingConditionCode = SalesOrderH.TradingConditionCode
and CustProd.ItemNo = inserted.ItemNo))

begin

raiserror('Save error ! , You do not insert Item which is not in Customer Product List .',16,1)
end

--raiserror('DaiWei is stupid ! ,  .',16,1)


/*
select CustomerCode,CustomerType,TradingConditionCode,ItemNo from SalesOrderD
inner join SalesOrderH on SalesOrderD.ReceiptCode = SalesOrderH.ReceiptCode
where not exists(select * from CustProd
where CustProd.CustomerCode = SalesOrderH.CustomerCode 
and CustProd.CustomerType = SalesOrderH.CustomerType
and CustProd.TradingConditionCode = SalesOrderH.TradingConditionCode
and CustProd.ItemNo = SalesOrderD.ItemNo)

select * from custprod where CustomerCode = 'TZ'
*/

 

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

 

posted on 2006-04-21 11:34  DaiWei  阅读(166)  评论(0编辑  收藏  举报

导航