为什么我做的触发器放在表上就不生效啊~求大神~~
ss_赊侈 2015-10-25 01:38:52 这个触发器测试了好久,只有放在icstockbill里面能生效,放在icstockbillentry不生效,放在t_log(日志表)也不生效,搞不懂啊~~~
set QUOTED_IDENTIFIER ON
go
ALTER trigger [updatebill] on [dbo].[t_Log]
for insert,update
as
begin
declare @FlogID int
select @FlogID=FlogID from inserted
--自动插入采购价格资料
if not exists(select 1
from icstockbill t3,icstockbillentry t2,t_SupplyEntry t1
where t2.finterid=t3.finterid and t2.fsourceinterid=0
and t1.FUsed=1
and t1.FSupID=t3.FSupplyID
and t1.FItemID=t2.fitemid
and t1.FQuoteTime=t3.fdate
and t1.FLastModifiedBy=t3.fbillerid
and t1.FLastModifiedDate=t3.fdate
and t2.fsourceinterid=0
and t2.finterid=t1.finterid
and t3.fbillno=(SELECT SUBSTRING(fdescription,4,9) from t_log where ffunctionid='K000601' and FlogID=@FlogID))
begin
INSERT INTO t_SupplyEntry(FBrNo,FUsed,FEntryID,FSupID,FItemID,FUnitID,FStartQty,FEndQty,
FPType,FPrice,FCyID,FDisCount,FLeadTime,
FQuoteTime,FDisableDate,FRemark, FLastModifiedBy,
FLastModifiedDate,finterid)select '0',1,(select max(fentryid)+1 from t_SupplyEntry),
t1.FSupplyID,t2.fitemid,t2.FUnitID,0,0.0000,1,t2.fprice,
1,0.000000,0,fdate,'2100-01-01','',t1.fbillerid,t1.fdate,t2.finterid
from icstockbill t1,icstockbillentry t2
where t1.finterid=t2.finterid and t2.fsourceinterid=0
and t1.fbillno=(SELECT SUBSTRING(fdescription,4,9) from t_log where ffunctionid='K000601' and FlogID=@FlogID)
end
if not exists(select t2.finterid from t_Supply t1,icstockbillentry t2,icstockbill t3
where t1.FBrNo=0 and t1.fsupid=t3.fSupplyid and t1.fitemid=t2.fitemid
and t1.fcurrencyid=1 and fpohighprice=0 and fptype=1 and t3.fbillno=(SELECT SUBSTRING(fdescription,4,9) from t_log where ffunctionid='K000601' and FlogID=@FlogID))
begin
insert into t_Supply (FBrNo,fsupid,fitemid,fcurrencyid,fpohighprice,fptype)
select 0,t3.fSupplyid,t2.fitemid,1,0,1
from icstockbill t3,icstockbillentry t2
where t2.finterid=t3.finterid
and t3.fbillno=(SELECT SUBSTRING(fdescription,4,9) from t_log where ffunctionid='K000601' and FlogID=@FlogID)
end
end