[DB-SIG] How to call function with cursor in-out parameter type?

Harri Pasanen harri.pasanen at trema.com
Wed Dec 10 07:03:29 EST 2003


Hello,

I'm a bit at loss how to make the following type of a call from Python 
DB API, cx_Oracle in this case:

SQL> desc myfunc
FUNCTION myfunc RETURNS NUMBER
 Argument Name                  Type                    In/Out 
Default?
 ------------------------------ ----------------------- ------ 
--------
 PID                            VARCHAR2                IN     DEFAULT
 CR1                            REF CURSOR              IN/OUT

SQL> var crs refcursor
SQL> var ret number
SQL> exec :ret := myfunc('YVESX',:crs)

SQL> print crs

        ID LIMIT_ID
...

So on return crs is a cursor containing a result set.

My initial idea was to do

v = cursor.var(cx_Oracle.CURSOR)
res = cursor.callfunc("myfunc", cx_Oracle.NUMBER, v)

but that does not work, I'm getting

"cx_Oracle.NotSupportedError: Variable_TypeByPythonType(): unhandled 
data type"

Any hints on how to go about this?

Harri







More information about the DB-SIG mailing list