Mysql stored procedures from Rails

Hi all,

I know stored procedures are considered evil around, but there are times
when you just have to use them. In the project I’m working on, I needed
to call a mysql5 stored procedure, but I only got an error message
saying “ActiveRecord::StatementInvalid: Mysql::Error: PROCEDURE
vc.testsp can’t return a result set in the given context: call testsp()”
I found out from here: http://bugs.mysql.com/bug.php?id=2658 that mysql
needs the flag CLIENT_MULTI_RESULTS set if you want to be able to return
result sets from stored procedures. The problem is that mysql_adapter.rb
doesn’t pass the flag parameter to the mysql connect function. When I
hacked it in there myself, things worked perfectly.

Am I going to about this the wrong way? Even though things work fine
now, I don’t want to have to hack this fix back in when new versions of
rails are released…

Cheers,
tomas

Tomas Larsson wrote:

Hi all,

I know stored procedures are considered evil around, but there are times
when you just have to use them. In the project I’m working on, I needed
to call a mysql5 stored procedure, but I only got an error message
saying “ActiveRecord::StatementInvalid: Mysql::Error: PROCEDURE
vc.testsp can’t return a result set in the given context: call testsp()”
I found out from here: http://bugs.mysql.com/bug.php?id=2658 that mysql
needs the flag CLIENT_MULTI_RESULTS set if you want to be able to return
result sets from stored procedures. The problem is that mysql_adapter.rb
doesn’t pass the flag parameter to the mysql connect function. When I
hacked it in there myself, things worked perfectly.

Am I going to about this the wrong way? Even though things work fine
now, I don’t want to have to hack this fix back in when new versions of
rails are released…

Cheers,
tomas

Could you possibly post the changes you made to mysql_adapter.rb? I
need to get a result set from a stored procedure into RoR too! Thanks
-T

Mabye the changes you made could be patched into the core file for
future
releases of RoR. I’d also suggest you post a diff of the file or just
the
changes you made to the adapter.

Best,
Ryan