"DELIMITER $$"附近出现错误

编程入门 行业动态 更新时间:2024-10-25 20:29:14
本文介绍了"DELIMITER $$"附近出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我从mysql控制台或MySQL Workbench更改Delimeter时,没有出现任何错误, 但是当我将相同的代码嵌入在ruby的rails上时,我得到了错误

when I change Delimeter from mysql console or MySQL Workbench I do not get any error, but when I embed the same code in ruby on rails I get error

mysql> DELIMITER $$ mysql>

没有错误.

但是

ActiveRecord::Base.connection.execute(%Q{ DELIMITER $$ })

给予:

ActiveRecord::StatementInvalid: Mysql2::Error: 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 'DELIMITER $$' at line 1:

推荐答案

DELIMITER实际上是MySQL命令行设置,而不是SQL: dev.mysql/doc/refman/5.0/en/mysql-commands.html .这意味着您不能以这种方式设置定界符.

DELIMITER is actually a MySQL command line setting, not SQL: dev.mysql/doc/refman/5.0/en/mysql-commands.html. That means that you can't set the delimiter in this way.

最重要的是,如果ActiveRecord::Base.connection.execute只允许您一次执行一条语句,这将无济于事(请参阅 www.seanr.ca/tech/?p=75 ).

On top of that, it wouldn't help if you could as ActiveRecord::Base.connection.execute only allows you to execute one statement at a time out of the box (see www.seanr.ca/tech/?p=75).

更多推荐

"DELIMITER $$"附近出现错误

本文发布于:2023-10-22 23:11:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:出现错误   quot   DELIMITER

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!