当我从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 $$"附近出现错误
发布评论