在rails(3.2.1,mysql2)app中,我想调用并显示过程的结果 我google并尝试了diff方式,但没有运气,问题仍然是相同的,这是我用来调用程序的代码snipet
ActiveRecord::Base.connection.execute("call sp_name(1,10)")
下面是执行此代码时出现的错误
Mysql2::Error: PROCEDURE sp_name can't return a result set in the given
context: call sp_name(1, 10)
ActiveRecord::StatementInvalid: Mysql2::Error: PROCEDURE sp_name can't
return a result set in the given context: call user_childs(1, 10)
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-
3.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `query'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290@sharetok/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `block in execute'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `execute'
from /home/ankit/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:214:in `execute'
答案 0 :(得分:1)
这是Rails的一个众所周知的问题,有关详细信息,请参阅此blog post。
我个人在某些应用程序中使用以下gist中的代码。
如果您想在rails代码中使用多个结果集,可以使用mysql2 gem
的分支