SQL Server gets the return value of the stored procedure (parameter returned), do not play the output

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.