I would like to execute a store procedure and get its returned value.
How can I do that?
To be specific, I use SQL Server 2008 and activerecord-sqlserver-
adapter 2.3.9. Here is what I tried, among others,
[code]
j:\myRailsApp ruby script\console
Loading development environment (Rails 2.3.9)
>> User.connection.execute_procedure("sp_getapplock", "file_1", "exclusive", "Session", 0)
=> []
[/code]
The problem is, exectue_procedure always returns [] here but I want
the return code value of that stored procedure, [url=http://
msdn.microsoft.com/en-us/library/ms189823.aspx]sp_getapplock[/url].
The return code value is critical for my program since it shows
whether the lock for file_1 is obtained or not. If it is greater or
equal to 0, the lock is acquired; otherwise, the lock is not acquired.
I have checked the source for execute_procedure. It seems it does not
check the return code value of the stored procedure. However, I might
be wrong as I am not versed in the SQLServer Adapter.
So, here is my question again: how can I execute a stored procedure
and get the its return code value?