create proc s @id int,@rkcksl int as begin
--取得被更改的物料编码,入库出库标志,入库原有数量
  declare @rkckbz varchar(8),@wuliaobm varchar(8),@rkcksl1 int
  select @rkckbz=rkckbz,@wuliaobm=wuliaobm ),@rkcksl1=rkcksl from table where id=@id--首先更改[要求当修改id=2时的rkcksl=15 时]
  update table set rkcksl=@rkcksl  where id=@id--更改id大于@id 的剩余数量
  if @rkckbz='入库'
  begin
  update table set shengyusl=shengyusl+(@rkcksl-@rkcksl1) where id>=@id and wuliaobm=@wuliaobm
  update table set shengyusl=shengyusl+(@rkcksl-@rkcksl1) where id>@id and wuliaobm=@wuliaobm and rkckbz='上年结转'
  end
  if @rkckbz='出库'
  begin
  update table set shengyusl=shengyusl-(@rkcksl-@rkcksl1) where id>=@id and wuliaobm=@wuliaobm
  update table set shengyusl=shengyusl-(@rkcksl-@rkcksl1) where id>@id and wuliaobm=@wuliaobm and rkckbz='上年结转'
  end
end