MySql calling stored procedure in a trigger _ MySQL-mysql tutorial

Source: Internet
Author: User
Tags sql error
MySql does not quite write a trigger when calling a stored procedure in a trigger. today, I encountered a syntax problem. I solved it with the help of a friend (DBA) and recorded it.

Requirement: the stored procedure gen_ci_property_value is called when CLASS_PROPERTY_REL deletes a record.

Problem feedback:

SQL error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimitercreate TRIGGER cpr_del after delete on CLASS_PROPERTY_REL for each row' at line 1
Solution:

DELIMITER $ create trigger cpr_del after delete on CLASS_PROPERTY_REL for each row begin call gen_ci_property_value (); END $ DELIMITER;
Explanation:

Because the statement for creating proc is a whole, you do not want to end the execution of a line, so you need to temporarily change the DELIMITER. after the completion, 'delimiter; 'is to change the DELIMITER back to the default

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.