Mysql stored procedure,

Source: Internet
Author: User

Mysql stored procedure,

Create a stored procedure

1. Create a stored procedure without parameters.

Delimiter // # The default end mark of mysql is a semicolon, and now it is changed to two slashes. Create procedure pro_student () begin delete from students; end // delimiter; # restore the default end flag.

2. Create a stored procedure with parameters.

Delimiter // create procedure pro_student (in sid int) begin select * from students where id = sid; end // delimiter;

3. Create a stored procedure with output parameters.

Delimiter // create procedure pro_student_count (out coun int) begin select count (*) into coun from students; end // delimiter; call pro_student_count (@ count); select @ count; # result: 2

. Call the stored procedure.

# Call method without parameters: call pro_student # call pro_student (1 );

4. delete a stored procedure

Drop procedure pro_student;

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.