DECLARE @dingdanid int DECLARE @fanhuizhi int
Set @dingdanid = 1
EXEC detects the order outbound eligibility @dingdanid, @fanhuizhi output (be careful not to forget output otherwise the return value is null)
Select @fanhuizhi
CREATE PROC dbo. Detect order out of stock eligibility
@dingdanID int, @returnValue int output
As
--Enter the variable order number
Set @returnValue = 1
--Monitoring the outbound eligibility of orders
--If the library is out, return 0
--If not out of the library and the order belongs to the assembly demand is less than equal to the inventory, that is, to meet the outbound status, return 1e; otherwise return 0
If ' out of stock ' = (select order status from Order 1 where order number = @dingdanID)
Begin
Set @returnValue = 0
Return @returnValue
End
declare @zongchengID nvarchar (50)
DECLARE @chazhi int
DECLARE employee_cursor Cursor for Select order 2. Assembly number, (stock-sum (order 2. Number of requirements)) as difference from order 2, assembly table where order number [email Protec Ted] and order 2. Assembly Number = Assembly table. Assembly Number GROUP BY order 2. Assembly number, Stock OPEN Employee_cursor
FETCH NEXT from Employee_cursor to @zongchengID, @chazhi
While @ @FETCH_STATUS = 0 BEGIN
if (@chazhi <0)
Begin Set @returnValue = 0
Return @returnValue
Break
End
FETCH NEXT from Employee_cursor to @zongchengID, @chazhi END
CLOSE Employee_cursor
Deallocate employee_cursor
Return @returnValue