Uniphase38
Uniphase38

Reputation: 31

Using cx_Oracle callfunc to get oracle objects

I'm trying to call an oracle pl/sql function returning an oracle object by using cx_Oracle's cursor.callfunc() but cannot bring it to work and found no help neither in the documentation nor on the net. my code:

connection = cx_Oracle.connect('myuser/mypass@myservice')
cursor = connection.cursor()
result = cursor.var(cx_Oracle.OBJECT)
cursor.callfunc('myfunction', result , [an_arg]) 

Traceback (most recent call last):
  File "...", line nn, in <module>
    result = cursor.var(cx_Oracle.OBJECT)
TypeError: expecting type name for object variables

Was somebody successful getting oracle objects using callfunc?

Many thanks in advance.

Upvotes: 3

Views: 5612

Answers (1)

Greg
Greg

Reputation: 2617

This works for me:

connection = cx_Oracle.connect('myuser/mypass@myservice')
cursor = connection.cursor()
result = cursor.callfunc('myfunction', cx_Oracle.OBJECT, [an_arg]) 

You'll need to replace cx_Oracle.OBJECT with the correct type; failing to do this returns the following error for me:

NotSupportedError: Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECTVAR

This site has some good examples: http://st-curriculum.oracle.com/obe/db/11g/r2/prod/appdev/opensrclang/python/python.htm#t9

Upvotes: 3

Related Questions