27,581
社区成员
发帖
与我相关
我的任务
分享CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
@B int
AS
BEGIN
-- 获取入库量对应的库存量为@D,判断入库量加库存量,如果小于等于最大库存量,进行下面
update C SET D=@D+@B
insert into A (B) value(@B)
END
GOdeclare @ismore int
select @ismore =case when C.D+isnull(A.B,0) >C.E then 1 else 0 end
from C
left join (select itemNo,sum(B) as B from #temp group by itemNo)A on A.itemNo=C.itemNo
where C.itemNo='001'
if @ismore=1 -->没有超过最高库存,则插入A表和C表
begin
insert into A(....) values(.....)
insert into C(....) values(.....)
end
select case when C.D+isnull(A.B,0) >C.E then '已超过最高库存' else '未超过' end
from C
left join A on A.itemNo=C.itemNo
where C.itemNo='001'