MySQL stored procedure requires delimiter

Source: Internet
Author: User

DELIMITER &&
CREATE PROCEDURE Syncadvertiser ()
BEGIN
DECLARE ID bigint;
DECLARE _cur CURSOR for SELECT ID from advertisers;
OPEN _cur;
REPEAT
FETCH _cur into ID;
Sql
UNTIL 1>0 END REPEAT;
CLOSE _cur;
END;
DELIMITER;

DELIMITER && and DELIMITER should be noted ; Two sentences,DELIMITER is the meaning of the separator, because MySQL defaults to ";" As a delimiter, if we do not declare the separator, then the compiler will treat the stored procedure as an SQL statement, the process of compiling the stored procedure will be error-free, so you have to use the DELIMITER keyword in advance to declare the current segment delimiter, so that MySQL will not be ";" As the code in the stored procedure, the code is not executed and the delimiter is restored after it is exhausted.

MySQL stored procedure requires delimiter

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.