Home > Database > Mysql Tutorial > MySql在触发器中调用存储过程_MySQL

MySql在触发器中调用存储过程_MySQL

WBOY
Release: 2016-05-31 08:49:00
Original
1325 people have browsed it

不太写触发器,今天遇到个语法问题,在朋友(DBA)的帮助下解决了,记录下来。

需求:在CLASS_PROPERTY_REL删除记录时,调用存储过程gen_ci_property_value

问题反馈:

SQL 错误 [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
Copy after login
解决方案:

DELIMITER $$CREATE TRIGGER cpr_del AFTER DELETE ON CLASS_PROPERTY_REL FOR EACH ROW BEGIN  CALL gen_ci_property_value();END$$DELIMITER ;
Copy after login
解释:

因为创建proc的语句是个整体,你不希望执行一行就结束了,所以需要临时改变一下定界符,结束后,‘DELIMITER ;’是把定界符再改回默认


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template