Mixing stored procedure call with RoR db calls in the same function gives errors


I am using ruby 1.8.5 with rails 1.2.3 and have made changes to
mysql_adapter.rb based on recommendations made here
http://wiki.rubyonrails.org/rails/pages/StoredProceduresInMySql to be
able to use stored procs in my code.

I have changed this call in mysql_adapter.rb

ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username,
password, database, port, socket], config)


ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username,
password, database, port, socket, 65536 + 131072], config)

as recommended. However I use connection.select_all(“call
spName(params)”) to execute my stored proc instead of using select_sp
as defined and recommended in the abovementioned article - partly
because select_all seemed to work fine and the article above was
written for some older version of rails as the lines numbers where
changes were to be made didn’t match with those in my version of
mysql_adapter.rb file.

However, after making that one change, while individual calls to
stored procs work fine now, when I mix stored proc calls with Rails
based database look ups (two separate lines of code in the same
function) I get the following error

Mysql::Error: Commands out of sync; you can’t run this command now.

In general I find very little documentation on usage of stored procs
in rails. I know it is not recommended but when you are forced to
there doesn’t seem to be much support available on this topic.

Thanks for any thoughts/pointers to help with this problem.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs