Skip to content

Cursor.callproc method #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cxoCursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,11 @@ static PyObject *cxoCursor_callProc(cxoCursor *cursor, PyObject *args,
return NULL;

// create the return value
numArgs = PyList_GET_SIZE(cursor->bindVariables);
numArgs = 0;
if (listOfArguments) {
//check already made in cxoCursor_call
numArgs = PySequence_Size(listOfArguments);
}
results = PyList_New(numArgs);
if (!results)
return NULL;
Expand Down
31 changes: 31 additions & 0 deletions test/Cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,37 @@ def testCallProc(self):
results = self.cursor.callproc("proc_Test", ("hi", 5, var))
self.assertEqual(results, ["hi", 10, 2.0])

def testCallProcAllKeywords(self):
"""test executing a stored procedure with arguments in keywordParameters"""
kwargs = dict(
a_InValue = "hi",
a_InOutValue = self.cursor.var(cx_Oracle.NUMBER),
a_OutValue = self.cursor.var(cx_Oracle.NUMBER),
)
kwargs['a_InOutValue'].setvalue(0, 5)
results = self.cursor.callproc("proc_Test", keywordParameters=kwargs)
self.assertEqual(results, [])
self.assertEqual(kwargs['a_InOutValue'].getvalue(), 10)
self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0)

def testCallProcOnlyLastKeyword(self):
"""test executing a stored procedure with last argument in keywordParameters"""
kwargs = dict(
a_OutValue = self.cursor.var(cx_Oracle.NUMBER),
)
results = self.cursor.callproc("proc_Test", ("hi",5), kwargs)
self.assertEqual(results, ["hi", 10])
self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0)

def testCallProcRepeatedKeywordParameters(self):
"""test executing a stored procedure with repeated argument in keywordParameters"""
kwargs = dict(
a_InValue = "hi",
a_OutValue = self.cursor.var(cx_Oracle.NUMBER),
)
self.assertRaises(cx_Oracle.DatabaseError, self.cursor.callproc,
"proc_Test", parameters=("hi",5), keywordParameters=kwargs)

def testCallProcNoArgs(self):
"""test executing a stored procedure without any arguments"""
results = self.cursor.callproc(u"proc_TestNoArgs")
Expand Down