skt
2008-Mar-20 05:28 UTC
Mixing stored procedure call with RoR db calls in the same function gives errors
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 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---