Create and use a MySQL Stored Procedure

Source: Internet
Author: User


The creation and use of MySQL stored procedures 1. CREATE a stored PROCEDURE: www.2cto.com SQL code CREATE PROCEDURE proc_name (out s int) -- create a stored procedure proc_name: The out parameter in the stored procedure name parameter list indicates that the parameter is the return value. The input value is in s. The parameter name int indicates that the parameter type is BEGIN. -- the stored procedure starts to SELECT * FROM tbl_name WHERE tbl_id = s; -- This stored procedure indicates querying the END of a tbl_id result in the tbl_name table with the value of s; -- the END of the stored procedure 2. CALL the Stored Procedure SQL code SET @ p = 0; -- SET the user variable and initialize CALL proc_name (@ p ); -- CALL the CALL command to CALL the stored procedure and place the set variables in the parameter list. Note: even if the stored procedure has no variables, write (). This is consistent with the method declaration in the program. view the Stored PROCEDURE SQL code SHOW PROCEDURE STATUS 4. delete Stored PROCEDURE SQL code DROP PROCEDURE pro_name -- followed by stored PROCEDURE name
 

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.