python-cx_Oracle/samples/RefCursor.py
Anthony Tuininga 74d9d71484 Use cx_Oracle.connect() in preference to cx_Oracle.Connection() in samples and
tests. Although the two are aliases of one another, it makes sense to be
consistent and to use the one that the DB API prefers as well.
2018-09-21 11:05:40 -06:00

32 lines
958 B
Python

#------------------------------------------------------------------------------
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# RefCursor.py
# Demonstrates the use of REF cursors with cx_Oracle.
#------------------------------------------------------------------------------
from __future__ import print_function
import cx_Oracle
import SampleEnv
connection = cx_Oracle.connect(SampleEnv.MAIN_CONNECT_STRING)
cursor = connection.cursor()
refCursor = connection.cursor()
cursor.callproc("myrefcursorproc", (2, 6, refCursor))
print("Rows between 2 and 6:")
for row in refCursor:
print(row)
print()
refCursor = connection.cursor()
cursor.callproc("myrefcursorproc", (8, 9, refCursor))
print("Rows between 8 and 9:")
for row in refCursor:
print(row)
print()