日期:2014-05-17  浏览次数:20432 次

sql先进先出在回退的问题
有没有sql高手知道 当数据库先进先出之后,然后在回退到初始态怎么写?
意思就是如下就是先进先出的存储过程
ALTER proc [dbo].[wsp] 
@wlcode nvarchar(50),--物料编号
@cost int         --出库量
as 
--先得出该货物的库存是否够 
declare @spare float --剩余库存 
select @spare= sum(inqty)-sum(foutqty) from a074 where materialcode=@wlcode
if(@spare>=@cost)                         
   begin 
    --根据入库id采用先进先出原则对货物的库存进行处理  
     update a074 set foutqty=                                                                                                                      
     case when (select @cost-isnull(sum(inqty),0)+isnull(sum(foutqty),0) from a074 where materialcode=@wlcode and mxid<=a.mxid and inqty!=foutqty)>=0 
     then a.inqty
     else                        
        case when (select @cost-isnull(sum(inqty),0)+isnull(sum(foutqty),0) from a074 where materialcode=@wlcode and mxid<a.mxid and inqty!=foutqty)<0 
        then 0 
        else (select @cost-isnull(sum(inqty),0)+isnull(sum(foutqty),0)+a.foutqty from a074 where materialcode=@wlcode and mxid<a.mxid and inqty!=foutqty) 
        end 
     end 
     from a074 a where materialcode=@wlcode and inqty!=foutqty 
   end 
else 
    raiserror('库存不足',16,1)    
    return 

,当用户在界面上点击保存的时候,我会从上往下修改sql出库数量,但是这个时候用户点击删除了。怎么把刚修改的结果又回退到修改之前呢? 求高手指点。(有点类是后进先出),在网上找了好久,都没找到办法。或者谁有更好的办法代替我原来的想法。
sql 数据库 存储

------解决方案--------------------
退货的流程应该怎么走就怎么写
难道他点一下删除 就回到之前没有点击保存的状态吗
------解决方案--------------------
引用:
对的。我就是这样想的,既然能从上往下修