0510
DECLARE @fitemid int
declare @fdcstockid int
declare @fqty decimal(18,10)
declare @fbatchno varchar(50)
DECLARE #point_cursor CURSOR
FOR
select fitemid,FDCStockID,fqty,fbatchno from ICStockBillEntry where finterid = 18605
OPEN #point_cursor
FETCH NEXT FROM #point_cursor INTO @fitemid,@fdcstockid,@fqty,@fbatchno
while @@fetch_status = 0
BEGIN
select fitemid,fstockid,fqty,fbatchno,* from ICInventory where FStockID=@fdcstockid and fbatchno=@fbatchno and fitemid=@fitemid
update ICInventory set fqty=fqty+@fqty where FStockID=@fdcstockid and fbatchno=@fbatchno and fitemid=@fitemid
select fitemid,fstockid,fqty,fbatchno,* from ICInventory where FStockID=@fdcstockid and fbatchno=@fbatchno and fitemid=@fitemid
FETCH NEXT FROM #point_cursor INTO @fitemid,@fdcstockid,@fqty,@fbatchno
END
CLOSE #point_cursor
DEALLOCATE #point_cursor