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

**URL:** <https://www.ruby-forum.com/t/mixing-stored-procedure-call-with-ror-db-calls-in-the-same-function-gives-errors/132444>\
**Category:** Rails\
**Created:** [March 20, 2008, 6:29am UTC](https://www.ruby-forum.com/t/mixing-stored-procedure-call-with-ror-db-calls-in-the-same-function-gives-errors/132444 "2008-03-20T06:29:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [March 20, 2008, 6:29am UTC](https://www.ruby-forum.com/t/mixing-stored-procedure-call-with-ror-db-calls-in-the-same-function-gives-errors/132444/1 "2008-03-20T06:29:04Z")

</div>

Folks,

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](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)

to

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.

-S
