Skip to content

Commit

Permalink
Added SQL_ATTR_CALL_RETURN attribute to return from stored procdure (#…
Browse files Browse the repository at this point in the history
…965)

Signed-off-by: ek <[email protected]>
  • Loading branch information
Earammak authored Oct 9, 2024
1 parent 72703f4 commit f8d4fc1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ibm_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -14176,6 +14176,7 @@ static PyObject *ibm_db_get_option(PyObject *self, PyObject *args)
case SQL_ATTR_CURSOR_TYPE:
case SQL_ATTR_ROWCOUNT_PREFETCH:
case SQL_ATTR_QUERY_TIMEOUT:
case SQL_ATTR_CALL_RETURN:
isInteger = 1;
snprintf(messageStr, sizeof(messageStr), "Option %d is considered integer", op_integer);
LogMsg(DEBUG, messageStr, fileName);
Expand Down Expand Up @@ -15581,6 +15582,7 @@ INIT_ibm_db(void) {
PyModule_AddIntConstant(m, "SQL_ATTR_NETWORK_STATISTICS", SQL_ATTR_NETWORK_STATISTICS);
PyModule_AddIntConstant(m, "SQL_ATTR_OVERRIDE_CHARACTER_CODEPAGE", SQL_ATTR_OVERRIDE_CHARACTER_CODEPAGE);
PyModule_AddIntConstant(m, "SQL_ATTR_OVERRIDE_CODEPAGE", SQL_ATTR_OVERRIDE_CODEPAGE);
PyModule_AddIntConstant(m, "SQL_ATTR_CALL_RETURN", SQL_ATTR_CALL_RETURN);
PyModule_AddIntConstant(m, "SQL_ATTR_OVERRIDE_PRIMARY_AFFINITY", SQL_ATTR_OVERRIDE_PRIMARY_AFFINITY);
PyModule_AddIntConstant(m, "SQL_ATTR_PARC_BATCH", SQL_ATTR_PARC_BATCH);
PyModule_AddIntConstant(m, "SQL_ATTR_PING_NTIMES", SQL_ATTR_PING_NTIMES);
Expand Down
62 changes: 62 additions & 0 deletions ibm_db_tests/test_sp_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Licensed Materials - Property of IBM
#
# (c) Copyright IBM Corp. 2007-2024
#

from __future__ import print_function
import sys
import unittest
import os
import ibm_db
import config
from testfunctions import IbmDbTestFunctions

class IbmDbTestCase(unittest.TestCase):

def test_sp_return(self):
obj = IbmDbTestFunctions()
obj.assert_expect(self.run_test_sp_return)

def run_test_sp_return(self):
conn = ibm_db.connect(config.database, config.user, config.password)

serverinfo = ibm_db.server_info( conn )
server = serverinfo.DBMS_NAME[0:3]

if (server == 'IDS'):
procedure = """CREATE PROCEDURE TEST_SP_RETURN( ); declare retval integer;set retval = 100;return retval;END PROCEDURE;"""
else:
procedure = """CREATE PROCEDURE TEST_SP_RETURN( )
LANGUAGE SQL
BEGIN
declare retval integer;
set retval = 100;
return retval;
End
"""

if conn:
try:
ibm_db.exec_immediate(conn, 'DROP PROCEDURE TEST_SP_RETURN')
except:
pass
ibm_db.exec_immediate(conn, procedure)

stmt = ibm_db.callproc(conn, "TEST_SP_RETURN",( ))
value =ibm_db.get_option(stmt, ibm_db.SQL_ATTR_CALL_RETURN,0)
print(value)

ibm_db.close(conn)
else:
print("Connection failed.")

#__END__
#__LUW_EXPECTED__
#100
#__ZOS_EXPECTED__
#100
#__SYSTEMI_EXPECTED__
#100
#__IDS_EXPECTED__
#100

0 comments on commit f8d4fc1

Please sign in to comment.