Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import cx_Oracle as cxo
  2.  
  3. class MyCursor(cxo.Cursor):
  4. def helloWorld(self):
  5. print "helloWorld"
  6.  
  7. class MyConnection(cxo.Connection):
  8. def cursor(self):
  9. return MyCursor(self)
  10.  
  11.  
  12.  
  13. if __name__ == '__main__':
  14. conStr = 'ants/<password>'
  15. db = MyConnection(conStr)
  16. c = db.cursor()
  17. c.execute("""
  18. create or replace procedure cx_test_cursor(
  19. val4 out sys_refcursor
  20. ) is
  21. begin
  22. open val4 for
  23. select 1 a from dual union all
  24. select 2 from dual;
  25. end;
  26. """)
  27.  
  28. result = c.callproc('ants.cx_test_cursor', [c.var(cxo.CURSOR)])
  29. c.execute('drop procedure cx_test_cursor')
  30. print result
  31. result[0].hellowWorld()
  32.  
  33. [<cx_Oracle.Cursor on <__main__.MyConnection to user ants@local>>]
  34. Traceback (most recent call last):
  35. File "cx_test2.py", line 32, in <module>
  36. result[0].hellowWorld()
  37. AttributeError: 'cx_Oracle.Cursor' object has no attribute 'hellowWorld'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement