Stored Procedure problem

View: New views
1 Messages — Rating Filter:   Alert me  

Stored Procedure problem

by jqm () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Lords of jRuby,

I want to submit something nice :

I'm currently trying to use MS SQL Server 2005 and rails 2.1 to play together nicely (using jRuby 1.1.3 and the lastest sqljdbc.jar). So far I've been quite confident I wouldn't have any problem until I hit those 'stored procedures'.

Imagine this SP which basically gets a int as parameter an returns the double of its value (basic, right?).
---------------------
CREATE PROCEDURE [dbo].[sp_test]
    @myParam int
AS
    select @myParam*2;
---------------------
This works perfectly in a SQL Management Studio :  Exec sp_test 2; ==> gives 4.. Great!

Let's move to Rails now...in a console (jruby script/console) in my actual project.
doing this : puts ActiveRecord.connection.select_value("Use MyDevDB;  Exec sp_test 2;")

AR returns an error: ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: A result set was generated for update.

I tried connection.execute, connect.select_all but they returns same error...

but what's the deal here? I'm not (at any moment) trying to open a recordset for any update, it's a dawn simple Stored Procedure giving me back a simple integer!

I've been looking on all SQL forums, on MSDN web site, etc.  it seems this error message comes from the SQL Server itself , but i guess that at any moment AR is not giving right infos to SQL who believes I try to open this recordset for update, right?

Anyone with a solution there?

Thanks!
Fred.

EDIT :
I just tried same situation using ruby...  
this works with "ActiveRecord::Base.connection.instance_variable_get("@connection")["AutoCommit"] = false"
so wtf isn't that correctly working with jRuby and sqljdbc.jar???  (rem : this autocommit is not available with this jdbc adapter)

EDIT 2:
there is well a setAutoCommit method available in the sqljdbc , but I have no clue how to use it... please help
LightInTheBox - Buy quality products at wholesale price