日期:2014-05-18 浏览次数:20757 次
create trigger up_SEOutStock on SEOutStock for insert as set nocount on if exists( select 1 from inserted c join seoutstockentry d on c.finterid=d.finterid join ( select fitemid,sum(fqty) 库存数量 from ICInventory group by fitemid) e on d.fitemid=e.fitemid where d.fqty>e.库存数量) begin declare @s varchar(1000) select @s=isnull(@s+',','')+f.fnumber from inserted c join seoutstockentry d on c.finterid=d.finterid join ( select fitemid,sum(fqty) 库存数量 from ICInventory group by fitemid) e on d.fitemid=e.fitemid join t_icitem f on d.fitemid=f.fitemid where d.fqty>e.库存数量 exec('raiserror(''物料代码为 '+@s+' 超出库存数,单据不允许保存!'',18,1)') rollback tran end set nocount off go
------解决方案--------------------
将" 变成' 试试
------解决方案--------------------
create trigger up_SEOutStock on SEOutStock for insert as set nocount on if exists( select 1 from inserted c join seoutstockentry d on c.finterid=d.finterid join ( select fitemid,sum(fqty) 库存数量 from ICInventory group by fitemid) e on d.fitemid=e.fitemid where d.fqty>e.库存数量) begin declare @s varchar(1000) select @s=isnull(@s+',','')+f.fnumber from inserted c join seoutstockentry d on c.finterid=d.finterid join ( select fitemid,sum(fqty) 库存数量 from ICInventory group by fitemid) e on d.fitemid=e.fitemid join t_icitem f on d.fitemid=f.fitemid where d.fqty>e.库存数量 exec('raiserror('物料代码为 char(39) +@s+ char(39) 超出库存数,单据不允许保存!',18,1)') rollback tran end set nocount off go
------解决方案--------------------
CREATE TRIGGER up_SEOutStock ON SEOutStock FOR INSERT AS SET NOCOUNT ON IF EXISTS( SELECT 1 FROM INSERTED c JOIN seoutstockentry d ON c.finterid = d.finterid JOIN ( SELECT fitemid, SUM(fqty) 库存数量 FROM ICInventory GROUP BY fitemid ) e ON d.fitemid = e.fitemid WHERE d.fqty > e.库存数量 ) BEGIN DECLARE @s VARCHAR(1000) SELECT @s = ISNULL(@s + ',', '') + f.fnumber FROM INSERTED c JOIN seoutstockentry d