MySQL database execution stored procedure issues

Source: Internet
Author: User

Today, a stored procedure is executed in the MySQL database, and because the MySQL data connection tool is not installed, it is executed in the black box and then the following problem is encountered:

Always said it was my problem with the syntax of the stored procedure, but looked for a long time did not see the problem, and then checked the morning information only to occur the problem:

in MySQL, ";" would be the end of an SQL statement, so when you execute a database script using the source command, when you encounter the ";" Symbol, the database will assume that you have finished writing a SQL statement, he will automatically execute this sentence, then there is a problem, To solve this problem, you can use the delimiter command to customize the end flag of a statement, and then you can execute the stored procedure successfully. Remember to change the end-of-statement flag at the end of the stored procedure.

Cases:

-- ------------------------------Procedure structure for ' proc_adder '-- ----------------------------DROP PROCEDURE IF EXISTS' Proc_adder ';D elimiter;;CREATEDefiner=' Root ' @ ' localhost 'PROCEDURE' Proc_adder ' (inchAint,inchBint, outsum int)BEGIN#Routine body goes here ...DECLARECint; ifA is NULL  Then SetA= 0; End if; ifB is NULL  Then SetB= 0; End if; Set sum  =A+b;END;;D Elimiter;

MySQL database performs stored procedure issues

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.