Suppose I have a stored procedure named procedure().
Running ActiveRecord::Base.connection.execute("CALL procedure()") will
give you a bunch of errors in different cases while using mysql2 adapter
ActiveRecord::StatementInvalid: Mysql2::Error: PROCEDURE can't return a
result set in the given context: procedure() PROCEDURE
ActiveRecord::StatementInvalid: Mysql2::Error: Commands out of sync; you
can't run this command now.
How can The problem be solved? Need Assistance.
It's a very important question which you have right now, fortunately I
think I know the answer, here I am giving you the solution ---
When MySQL runs stored procedure it has to know that client can handle
multiple result sets.
We will create patch file for that in our initializer folder of our
Create mysql2_adapter.rb file in config/initializers with the following
# Overriding ActiveRecord::Base.mysql2_connection
# method to allow passing options from database.yml
Thanks Zinia for the reply and I think I got the answer.
Zinia Dutta Gupta wrote in post #1141735: