[python-win32] Getting output parameters from stored procedures

Vernon Cole vernondcole at gmail.com
Wed Jun 20 17:43:25 CEST 2012


Michael:
Last time I looked at the code of django-mssql it was using a fork of
adodbapi, not the code I maintain, which is included with pywin32.
Nevertheless, I don't think there are any changes in the return parameter
handling between the two forks.

I just ran across a related page on the AS/400 Python site (of all places)
which led me to thinking that I don't really understand how return
parameters are supposed to work. I have just blindly kept the code that
Ekelund wrote. The test in adodbapi is probably too simple to pick up any
edge cases, and the AS/400 version is interesting enough to make me say
"Huh?"

I think I'll run a version of your question into the python database group,
and see what they say.  It's definitely weird and should either be made
more obvious or documented, or both.  Let's keep this discussion running.
--
Vernon

On Wed, Jun 20, 2012 at 8:50 AM, Michael Manfre <mmanfre at gmail.com> wrote:

> I'm the maintainer of django-mssql and I've run in to an odd behavior when
> trying to retrieve a stored procedure's output parameters. The parameters
> (including return value) appear to only get fetched when the last recordset
> for the stored procedure is loaded. This last recordset appears as if the
> underlying layer is doing a select, and adding this extra recordset, for
> the parameters.
>
> The observed behavior is equivalent to this bit of SQL.
>
> DECLARE @retval int, @someOut int
>> exec @retval = uspReturnsAResultSetOrTwo @someOut OUTPUT
>> SELECT @retval, @someOut
>>
>
> I haven't been able to find any documentation stating that this is the
> intended behavior and this doesn't match my experience of using stored
> procedures with ADO.NET. Is this expected behavior? Is there some
> combination of cursor types or attributes to get the output parameter
> values without fetching/skipping all the recordsets?
>
> Regards,
> Michael Manfre
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120620/b29446e1/attachment-0001.html>


More information about the python-win32 mailing list