Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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].hellowWorld()
- [<cx_Oracle.Cursor on <__main__.MyConnection to user ants@local>>]
- Traceback (most recent call last):
- File "cx_test2.py", line 32, in <module>
- result[0].hellowWorld()
- AttributeError: 'cx_Oracle.Cursor' object has no attribute 'hellowWorld'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement