使用cx_Oracle callfunc获取oracle对象
作者:互联网
我试图通过使用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
标签:cx-oracle,python 来源: https://codeday.me/bug/20191201/2083532.html