python - 使用 cx_Oracle callfunc 获取 oracle 对象

标签 python cx-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

关于python - 使用 cx_Oracle callfunc 获取 oracle 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9064856/

相关文章:

Python解包错误

Python检测高斯模糊

Python Matplotlib : add legend with the exact value of a mean lien

python - 为什么 b[ :]=a mutates list b?

python - 在数据框中找到最后一个值和相应的列名

python - cx_oracle 和 python 2.7

python - cx_Oracle 忽略 order by 子句

python - 从python调用存储过程时获取列名和数据

python - 为什么 cx_oracle execute() 现在不喜欢我的字符串?

python - 在 Python 中使用 cx_Oracle 和 xlrd 的带有列表列表的 executemany() 返回 TypeError