MYSQL导入存储过程时出现错误1064
我正在导入一个刚刚从开发服务器导出到生产服务器的存储过程,并且在 phymyadmin 中遇到以下错误。
SQL query: Documentation
$$ CREATE DEFINER = `devuser`@`localhost` FUNCTION `get_refundable_amount` (
enrol_id INT
) RETURNS double( 10, 2 ) READS SQL DATA BEGIN DECLARE refundable_amount double( 10, 2 ) DEFAULT 0;
SELECT (
sum( P.amount ) - EI.amount
)
INTO refundable_amount
FROM site_payment_processed AS P
INNER JOIN site_user_enroled AS E ON ( P.enrol_id = E.id
AND P.payment_type = 'Refund' )
INNER JOIN site_user_enroled_invoice AS EI ON EI.enrol_id = E.id
WHERE E.id = enrol_id
GROUP BY E.id;
RETURN (
refundable_amount
);
END$$
MySQL said: Documentation
#1064 - 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 '$
CREATE DEFINER=`devuser`@`localhost` FUNCTION `get_refundable_amount`' at line 1
I'm importing a stored procedure which I just exported from my development server into my production one and I ran into the following error in phymyadmin.
SQL query: Documentation
$ CREATE DEFINER = `devuser`@`localhost` FUNCTION `get_refundable_amount` (
enrol_id INT
) RETURNS double( 10, 2 ) READS SQL DATA BEGIN DECLARE refundable_amount double( 10, 2 ) DEFAULT 0;
SELECT (
sum( P.amount ) - EI.amount
)
INTO refundable_amount
FROM site_payment_processed AS P
INNER JOIN site_user_enroled AS E ON ( P.enrol_id = E.id
AND P.payment_type = 'Refund' )
INNER JOIN site_user_enroled_invoice AS EI ON EI.enrol_id = E.id
WHERE E.id = enrol_id
GROUP BY E.id;
RETURN (
refundable_amount
);
END$
MySQL said: Documentation
#1064 - 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 '$
CREATE DEFINER=`devuser`@`localhost` FUNCTION `get_refundable_amount`' at line 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用新的分隔符定义包围存储过程代码的主体(例如,从 ; 到 $$)。
Surround the body of the stored procedure code with a new definition of the delimiter (e.g., from ; to $$).
在 mysql 中创建函数不起作用 - 错误 1064 中提出的解决方案完全够了。
问题出在 phpMyAdmin 上。从 mysql 命令行运行效果很好。
Solution presented in Creating functions in mysql doesnt work - Error 1064 suffices completely.
The issue was with phpMyAdmin. Running from the mysql command line worked fine.