[egenix-users] Passing a value from stored procedure to python?

Griff McClellan griffmcc at comcast.net
Sun Jan 21 17:13:40 CET 2007


Hello,

I need to pass a value from a stored procedure or function to the calling 
python script.  Nothing I have tried has worked.  I am using mx.ODBC.Windows 
with Oracle 10g on Windows XP.

Can someone show me how a value, say 66, can be passed from a stored 
procedure/function to a python variable?

Thank you,
Griff


Here are the things I've tried and the problems I have encountered.  Note 
that the variable "cur" is a cursor.

1.  There is no way to get the value returned from a stored function into 
the python script.  Here's an example of the problem:

>>> cur.execute("declare n number; begin n := num_test_sf(); 
>>> dbms_output.put_line(n); end;")
-1

where:
CREATE FUNCTION "CRAIG"."NUM_TEST_SF"
return number
is
begin
return 66;
end;

The root of the problem appears to be that you can't execute an anonymous 
block.
>>> cur.execute("declare n number; begin n := 66; end;")
-1

2. There is no way for a stored procedure to return a result set.

>>> cur.execute("call resultset_test_sp()")
1
>>> cur.fetchall()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
mxODBC.ProgrammingError: missing result set

where:
CREATE PROCEDURE "CRAIG"."RESULTSET_TEST_SP"
is
n number := -1;
begin
select 66 into n from dual;
end;

3. callproc() is not implemented.

>>> cur.callproc("num_test_sf()")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: callproc

>>> cur.callproc
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: callproc

>>> cur.execute
<built-in method execute of mxODBC Cursor object at 0x00A8D330>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman-archives/egenix-users/attachments/20070121/b179d858/attachment.htm


More information about the egenix-users mailing list