开发者

ActiveRecord::StatementInvalid (Mysql::Error: PROCEDURE db_name.proc_spName can't return a result set in the given context:

开发者 https://www.devze.com 2023-01-07 10:34 出处:网络
I have use activerecord to access data from db. It works fine in localhost but when I tried it on another server, I get the following errors:

I have use activerecord to access data from db. It works fine in localhost but when I tried it on another server, I get the following errors:

ActiveRecord::StatementInvalid (Mys开发者_Python百科ql::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, below is the line where I get the following errors

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

Any ideas would be greatly appreciated..


As BJG showed you that link pretty much explains it; as ActiveRecord is expecting a result set to be returned. You could use something along these lines for calling stored procedures using execute.

 SELECT proc_getresults() as Results FROM TABLE ...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号