On Monday, January 6, 2014 2:41:23 AM UTC-8, Jurgens du Toit wrote:
>
> Hey
>
> Although the call_mssql_sproc functionality works nicely, I ran into an 
> issue when I try to retrieve datasets using it. As it returns the first row 
> of the dataset, if the stored proc returns a result set, you'll get the 
> first row of the result set, not the row containing the numrows and result 
> values.
>
> I realised that I can do the following, though:
>
> result = DB.fetch("EXEC ResultSetStoredProc ?, ?, ?", 'Filter', 
> (Date.today - 6), (Date.today + 1))
>
> I'm trying to think of a way to combine these two methods, but I'm not 
> sure if that's necessary, or even how to do it properly.
>
> Thoughts?
>

Assuming you don't need the return code of the stored procedure, I'd say 
just use your current DB.fetch code.  

If you do need the result code of the procedure, you could modify 
call_mssql_sproc to add an option to return the dataset instead of calling 
dataset.first, but I don't think that will work correctly, because it will 
result in the dataset returning two separate types of data (one for the 
rows returned by the stored procedure, and one for the final row with the 
result code).  Properly handling that probably requires setting the 
variables in the first dataset, but issuing an extra select to retrieve the 
values in another dataset.  That requires you check out a connection and 
use it for both queries.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to