作者:欢乐乡村烤鸭8321 | 来源:互联网 | 2023-10-13 10:44
declare@dingdanidintdeclare@fanhuizhiintset@dingdanid1exec检测订单出库资格@dingdanid,@fanhuizhiout
declare @dingdanid int declare @fanhuizhi int
set @dingdanid = 1
exec 检测订单出库资格 @dingdanid ,@fanhuizhi output (注意别忘了output否则返回值是NULL)
select @fanhuizhi
create proc dbo.检测订单出库资格
@dingdanID int, @returnValue int output
as
-- 输入变量 订单编号
set @returnValue = 1
-- 监测订单的出库资格
-- 如果已出库,返回0
-- 如果未出库并且该订单所属的总成需求量均小于等于库存,即满足出库状态,返回1e;否则返回0
if ‘已出库‘ = (select 订单状态 from 订单1 where 订单编号 = @dingdanID)
begin
set @returnValue = 0
return @returnValue
end
declare @zongchengID nvarchar(50)
declare @chazhi int
DECLARE Employee_Cursor CURSOR FOR select 订单2.总成编号,(库存量- sum(订单2.需求数量)) as 差值 from 订单2 , 总成表 where 订单编号=@dingdanID and 订单2.总成编号 = 总成表.总成编号 group by 订单2.总成编号,库存量 OPEN Employee_Cursor
FETCH NEXT FROM Employee_Cursor into @zongchengID,@chazhi
WHILE @@FETCH_STATUS = 0 BEGIN
if(@chazhi <0 )
begin set @returnValue = 0
return @returnValue
break
end
FETCH NEXT FROM Employee_Cursor into @zongchengID,@chazhi END
CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor
return @returnValue
SqlServer 获得存储过程的返回值(参数返回),别玩了output,,
SqlServer 获得存储过程的返回值(参数返回),别玩了output