问题
Trying to call an existing stored procedure, but using named parameters, first parameter should retain default value (in this case NULL).
I've spent way too long trying to get this working, any ideas?
create or replace procedure so_test(p1 in varchar2 default null, p2 in varchar2 default null, p3 in varchar2 default null) as
begin
null;
end;
import cx_Oracle
db = cx_Oracle.connect('/@XTS_DEV.CLIENT')
cur = db.cursor()
cur.callproc("so_test", ('X', 'Y', 'Z'))
cur.callproc("so_test(p2=>:1, p3=>:2)", ('Y', 'Z'))
Traceback (most recent call last):
File "C:\Users\PatrickJolliffe\so_test.py", line 5, in <module>
cur.callproc("so_test(p2=>:1, p3=>:2)", ('Y', 'Z'))
cx_Oracle.DatabaseError: ORA-06550: line 1, column 7:
PLS-00801: internal error [22503]
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
回答1:
The documentation (http://cx-oracle.readthedocs.io/en/latest/cursor.html#Cursor.callproc) covers this but since no examples are provided there I can see how that might be confusing. :-)
For your example, this is what you want:
cursor.callproc("so_test", keywordParameters = dict(p2 = "Y", p3 = "Z"))
来源:https://stackoverflow.com/questions/40586019/named-parameters-with-a-oracle-stored-procedure-in-python