我在oracle(lro_dummy)中有一个自定义类型。我也有一个程序。我看起来像这样:
procedure dummyLro
(
i_dummy in lro_dummy,
o_dummy out lro_dummy
)is
begin
o_dummy := lro_dummy('asdf');
end dummyLro;
现在我想用python和cx_Oracle调用这个过程。这看起来像这样:
def test(db_con):
cur = db_con.cursor()
try:
procedure_params = {}
procedure_params["i_dummy"] = cur.var(cx_Oracle.OBJECT, typename="lro_dummy")
procedure_params["o_dummy"] = cur.var(cx_Oracle.OBJECT, typename="lro_dummy")
cur.callproc("test.dummyLro", [], procedure_params)
之后o_dummy
有一个值,因为
str(procedures_params["o_dummy"])
返回
'<cx_Oracle.OBJECT with value <cx_Oracle.Object ???.LRO_DUMMY at 0x10492c9c0>>'
但我无法访问我的属性。该属性列在
中procedure_params["o_dummy"].type.attributes
但是我找不到
中的值procedure_params["o_dummy"]
我错了什么?
我正在使用Python 3.6
,cx_Oracle 5.3
,InstantClient 11.2
,Oracle-Server 11
答案 0 :(得分:0)
我有同样的问题。根据“文档”(http://www.oracle.com/technetwork/articles/prez-stored-proc-084100.html),它应该按照你的方式工作,但它对我不起作用。据我所见,传入proc的params没有变异。而是返回新对象。这对我有用:
i_dummy = cursor.var(cx_Oracle.OBJECT, typename='lro_dummy')
o_dummy = cursor.var(cx_Oracle.OBJECT, typename='lro_dummy')
[something, returned_o_dummy] = cur.callproc("test.dummyLro", [], [i_dummy, o_dummy])
print(returned_o_dummy.DUMMY)