我试图扩展一个游标,它是在一个过程返回sys_refcursor时创建的。解决方案How to extend OracleCursor class from cx_Oracle适用于连接.cursor()但不适用于sys\refcursor。在
import cx_Oracle as cxo
class MyCursor(cxo.Cursor):
def helloWorld(self):
print "helloWorld"
class MyConnection(cxo.Connection):
def cursor(self):
return MyCursor(self)
if __name__ == '__main__':
conStr = 'ants/<password>'
db = MyConnection(conStr)
c = db.cursor()
c.execute("""
create or replace procedure cx_test_cursor(
val4 out sys_refcursor
) is
begin
open val4 for
select 1 a from dual union all
select 2 from dual;
end;
""")
result = c.callproc('ants.cx_test_cursor', [c.var(cxo.CURSOR)])
c.execute('drop procedure cx_test_cursor')
print result
result[0].helloWorld()
结果
^{pr2}$有什么办法扩展这个光标吗?在
这是可能的,只有在cx®Oracle 6和更高版本。在
相关问题 更多 >
编程相关推荐