日期:2014-05-18  浏览次数:20522 次

程序调用sql触发器问题
SQL code

-- 自己建了一个触发器,手工输入数据能触发,价格会变成1234
create trigger triGA
on GatheringVouchDetail
    for insert
as
    declare @id nvarchar(1000)
    select @id=fchrGatheringVouchDetailID from inserted
    update GatheringVouchDetail set flotMoney=1234 where fchrGatheringVouchDetailID=@id

-- 当我开程序选择商品录入商品信息的时候,却没有更改价格的数据
-- 后台我跟踪了下,是存在insert的
insert bulk GatheringVouchDetail ([fchrGatheringVouchDetailID] UniqueIdentifier, [fchrSettleID] UniqueIdentifier, [fchrGatheringVouchID] UniqueIdentifier, [flotMoney] Decimal(28,6), [ftinOrder] Int, [fchrBankName] NVarChar(100) COLLATE Chinese_PRC_CI_AS, [fchrBankAccNo] NVarChar(50) COLLATE Chinese_PRC_CI_AS, [fchrNotesNo] NVarChar(50) COLLATE Chinese_PRC_CI_AS, [fbitVipNoPoint] Bit, [fbitIsGiftToken] Bit, [flotOverflowMoney] Decimal(28,6), [fbitIsStoredCard] Bit, [fbitBank] Bit)
-- 数据的确插入GatheringVouchDetail这张表了,但没有执行我这个触发器
-- 各位大牛,这是什么问题?



------解决方案--------------------
那证明触发器还是有问题啊。

create trigger triGA
on GatheringVouchDetail
after insert --试试 
as

------解决方案--------------------
SQL code

create trigger triGA
on GatheringVouchDetail
    for insert
as
    update GatheringVouchDetail set flotMoney=1234 
from inserted i where  GatheringVouchDetail.fchrGatheringVouchDetailID=i.fchrGatheringVouchDetailID


--try

------解决方案--------------------
create trigger triGA
on GatheringVouchDetail
for insert
as
begin
RAISERROR ('Notify||||', 16, 10);
end
go