0118工作备份

select * from ICTransType
select * from ICTemplateEntry where fid='B08'
select * from ppbom where FBillNo='PBOM000278'
select * from ppbomentry where FInterID=1278
select ficmointerid from ICStockBillEntry
select * from t_Department
select * from t_Item where FItemClassID=2
select a1.fitemid,a1.FAuxQty,a1.FICMOInterID from ICStockBillEntry a1 inner join ppbom b1 on a1.FICMOInterID=b1.FICMOInterID

inner join ICStockBill c1 on a1.finterid=c1.finterid where c1.FTranType=28
select * from ppbom where FICMOInterID=1380
select fitemid,FAuxStockQty from ppbomentry where FInterID=1618

DECLARE @FFAUXQTY decimal(18,10)
DECLARE @FITEMID int
DECLARE @FDCSTOCKID int
DECLARE @finterid int
DECLARE @FAuxStockQty int
DECLARE @FTranType int
DECLARE @FAuxQtyMust decimal(18,10)
DECLARE @FICMOInterID int
DECLARE @ppbomfinterid int
DECLARE @FQTY decimal(18,10)
DECLARE @FAUXQTY decimal(18,10)
DECLARE #point_cursor CURSOR
FOR
SELECT a1.FItemID ,a1.FAuxQty,a1.FICMOInterID from
ICStockBillEntry a1 inner join ppbom b1 on a1.FICMOInterID=b1.FICMOInterID
inner join ICStockBill c1 on a1.finterid=c1.finterid where c1.FTranType=28
OPEN #point_cursor
FETCH NEXT FROM #point_cursor INTO @fitemid,@FAuxStockQty,@FICMOInterID
while @@fetch_status = 0
BEGIN

select @ppbomfinterid=finterid from PPBOM where FICMOInterID=@FICMOInterID
update ppbomentry set FAuxStockQty=FAuxStockQty+@FAuxStockQty where FInterID=@ppbomfinterid and FItemID=@FITEMID
FETCH NEXT FROM #point_cursor INTO @fitemid,@FAuxStockQty,@FICMOInterID
END
CLOSE #point_cursor
DEALLOCATE #point_cursor

update ppbomentry set FAuxStockQty=0

原文地址:https://www.cnblogs.com/xujiating/p/6295995.html