2017-06-02 82 views
0

我在oracle(lro_dummy)中有一個自定義類型。我也有一個程序。我看起來像這樣:cx_Oracle.OBJECT中的值缺失

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.6cx_Oracle 5.3InstantClient 11.2Oracle-Server 11

+0

procedure_params [「o_dummy」] .type.attributes?中列出的屬性是什麼? –

+0

它返回包含一個項目的'cx_Oracle.ObjectAttribute DUMMY'數組。 name屬性的值是'DUMMY' – Lee

+0

所以你應該可以通過procedure_params [「o_dummy」]來訪問它。DUMMY? –

回答

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)