Replies: 3 comments 4 replies
-
It is actually simpler than you think! :-) with db.cursor() as cursor:
my_in_var = 'test IN var...'
my_out_param = cursor.var(oracledb.DB_TYPE_VARCHAR)
params = {
"my_in_var": my_in_var,
"my_out_param": my_out_param
}
try:
my_ret_val = cursor.callfunc(
"test_function", oracledb.DB_TYPE_NUMBER, keyword_parameters=params
)
message = my_out_param.getvalue()
logger.info(
f"Out Message: {message}"
)
return True
except oracledb.DatabaseError as exception:
(error,) = exception.args
message = error.message
logger.error(f"Database error calling test_function: {message}")
return False Note the documentation which also contains a reference to a sample that should help further. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much. That did the trick. If I could ask a follow up question. I am having issues with the out param of a large legacy function. What would cause the following error? "oracledb.Var of type DB_TYPE_VARCHAR with value None" My procedure has an out VARCHAR2 with that value. It is a very large proc that I can't share here due to IP. I was wondering if you could just tell me generally what causes that error. Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I created a simple oracle function to demonstrate this issue:
Calling it within Oracle works fine:
Calling it with python-oracledb 2.2.1 and python 3.12 returns an error:
Database error calling test_function: DPY-2007: expected a type
I've tried cursor.var(int) and various other iterations but nothing seems to work. Is this a bug or am I doing something wrong? This all worked with cx_Oracle without any issues.
If it matters, it's being run in an AWS Lambda using the following layer/Dockerfile. It's Oracle 19.
Beta Was this translation helpful? Give feedback.
All reactions