When I try to call a stored procedure from Rails, I get this exception:
ActiveRecord::StatementInvalid: Mysql::Error: PROCEDURE pipeline-ws_development.match
Would it work to wrap the procedure in a function? If Ruby's barfing due to no rows returned (...can't return a result set in the given context...
), this may fix it:
DELIMITER $ CREATE PROCEDURE tProc() BEGIN SET @a = 'test'; END; $ CREATE FUNCTION tFunc() RETURNS INT BEGIN CALL tProc(); RETURN 1; END; $ DELIMITER ; SELECT tFunc() FROM DUAL; >> 1 SELECT @a FROM DUAL; >> 'test'
Although, realistically, this isn't a very extensible solution.
Followup: I'm pretty n00by at Ruby/ActiveRecord, but this example definitely works
ActiveRecord::Base.establish_connection(authopts) class TestClass < ActiveRecord::Base end test_class = TestClass.new puts %{#{test_class.connection.select_one('SELECT tFunc() AS tf FROM DUAL')}} >> tf1
Using CALL tProc()
resulted in an error similar to yours.