ActiveRecord :: StatementInvalid(Mysql :: Error:PROCEDURE db_name.proc_spName无法在给定的上下文中返回结果集:

时间:2010-07-12 10:50:43

标签: ruby-on-rails ruby activerecord

我使用activerecord从db访问数据。它在localhost中工作正常但是当我在另一台服务器上尝试它时,我收到以下错误:

ActiveRecord::StatementInvalid (Mysql::Error: PROCEDURE db_name.proc_spName can't return a result set in the given context: CALL proc_spName(............)):
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:310:in `execute'
    /app/controllers/keywordprocessor_controller.rb:306:in `result'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `send'

BTW,下面是我收到以下错误的行

sql = "CALL proc_getresults"
res = ActiveRecord::Base.connection.execute(sql)

任何想法都将受到高度赞赏..

1 个答案:

答案 0 :(得分:2)

正如BJG向您展示链接几乎解释了它;因为ActiveRecord期望返回结果集。您可以使用这些行中的某些内容来使用execute来调用存储过程。

 SELECT proc_getresults() as Results FROM TABLE ...