When I try to call a stored procedure from Rails, I get this exception:
ActiveRecord::StatementInvalid: Mysql::Error: PROCEDURE pipeline-ws_development.match
I've submitted a patch to Rails 2.3.4 which gives a configuration option to fix this problem. Please stop by my ticket and show your support for it!
https://rails.lighthouseapp.com/projects/8994/tickets/3151-mysql-adapter-update-to-enable-use-of-stored-procedures
Are you using ActiveRecord::Base.connection.execute? This method should allow you to execute some arbitrary SQL statement that isn't naively supported in the Active Record wrapper.
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.