我试图通过使用 cx_Oracle 的 cursor.callfunc() 调用返回 oracle 对象的 oracle pl/sql 函数,但无法使其正常工作,并且在文档和网络上都找不到任何帮助。 我的代码:
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
是否有人使用 callfunc 成功获取了 oracle 对象?
非常感谢。
最佳答案
这对我有用:
connection = cx_Oracle.connect('myuser/mypass@myservice')
cursor = connection.cursor()
result = cursor.callfunc('myfunction', cx_Oracle.OBJECT, [an_arg])
您需要将 cx_Oracle.OBJECT 替换为正确的类型;不这样做会为我返回以下错误:
NotSupportedError: Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECTVAR
这个网站有一些很好的例子:http://st-curriculum.oracle.com/obe/db/11g/r2/prod/appdev/opensrclang/python/python.htm#t9
关于python - 使用 cx_Oracle callfunc 获取 oracle 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9064856/