2012-01-30 136 views
3

我想通過使用cx_Oracle的cursor.callfunc()來調用一個oracle pl/sql函數來返回一個oracle對象,但不能使它工作,在文檔中也找不到任何幫助互聯網。 我的代碼:使用cx_Oracle callfunc來獲取oracle對象

connection = cx_Oracle.connect('myuser/[email protected]') 
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 

用別人成功獲得Oracle對象callfunc?

非常感謝提前。

回答

3

這個工作對我來說:

connection = cx_Oracle.connect('myuser/[email protected]') 
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