DB API question - where is a stored procedure's return value?

S

Skip Montanaro

I've stumbled on a problem with the python-sybase module. If I have a
stored procedure like this:

create stored procedure test_proc
as
return 1

and call it from Python like this:

curs.callproc("test_proc", {})

it's not clear to me where the return status is stored. Currently, the
python-sybase module provides (I believe) the ability to set output
parameters (those specified as such in the argument dictionary), and
you can iterate over all the result sets the stored procedure
produces.

Looking at the Python database API (PEP 249), I saw no mention of the
return status:

..callproc( procname [, parameters ] )

(This method is optional since not all databases provide stored procedures. [3])

Call a stored database procedure with the given name. The sequence of
parameters must contain one entry for each argument that the procedure
expects. The result of the call is returned as modified copy of the
input sequence. Input parameters are left untouched, output and
input/output parameters replaced with possibly new values.

The procedure may also provide a result set as output. This must then
be made available through the standard.fetch*() methods.

I see no mention of how to handle the return value. The "modified copy
of the input sequence" is just that. In the case of the python-sybase
module, any parameter values in the input dictionary of type
DataBufType are rewritten with values from the first row of the first
result set. The Cursor class also defines a _status_result() method,
which sounds promising. I haven't had a chance to try it out yet. My
concern is more that the Python database API doesn't mention stored
procedure return values at all.

What do other database adaptors do about stored procedure return
values? Does PEP 249 need revision?

Skip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top