How to Use return in the mysql Stored Procedure

Source: Internet
Author: User


As we all know, mysql stored procedures cannot use the return statement. Only storage functions have this function. Is there any keyword that replaces return? No! No keywords like exit or quit! What should I do? Use the leave keyword, which can mimic the return behavior. For example, SET FOREIGN_KEY_CHECKS = 0; -- export Procedure structure for sp_test_return -- ------------------------------ drop procedure if exists 'SP _ test_return '; DELIMITER ;; create procedure 'SP _ test_return '(In num integer) label_pro: begin www.2cto. comif num> 3 then leave label_pro; else select num as exeuted; end if; end; DELIMITER; in this example, the entry of the entire stored procedure is marked, when you need to exit the stored procedure, as long as the leave + mark is Yes.
Author crocodile

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.