ActiveRecord :: StatementInvalid (Mysql :: Error: PROCEDURE db_name.proc_spName cannot return the result set in the given context:

I have an activerecord function 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 (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'

By the way, below is the line where I get the following errors

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

Any ideas would be very helpful.

+3
source share
1 answer

As the BJG showed, this link pretty much explains this; because ActiveRecord expects the result set to be returned. You can use something in these lines to call stored procedures with execute.

 SELECT proc_getresults() as Results FROM TABLE ...
+2

Source: https://habr.com/ru/post/1754213/


All Articles