MySQL Stored procedure Learning

Source: Internet
Author: User

One: MySQL creates a stored procedure that modifies a table field

drop procedure if exists pr_test;

CREATE PROCEDURE Pr_test ()

Begin
declare var int; declare var1 int;
Set var=416; Set var1=420;
While var<850001 do
Update xxx Set bb= ' 217 ', aa= ' 237 ' where ID between Var and var1;
Set var=var+10;
Set var1=var1+10;
End while;
End

Two: Calling a stored procedure

Call Pr_test ();

Three: note the

1) at the end of each statement in the MySQL stored procedure, add a semicolon ";"

2) If the MySQL stored procedure contains multiple MySQL statements, the BEGIN END keyword is required

3) mysql stored procedure is required, even if there is no parameter, "()"

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.