Reputation: 1
I would like to execute an Oracle procedure in Python. The procedure on the SQL side is well written. In the Python code, it receives errors: ORA-06550 and PLS-00306 - DatabaseError.
con = cx_Oracle.connect('***********')
cur = con.cursor()
faktura= "QQ0009365/21"
numer_listu = "421435636356536"
kod_k = int(112377)
out_data=str()
t = cur.callproc('QQ.ECOMMERCE.ZMIANA_OPISU_LIST_PRZEWOZOWY',[numer_listu,kod_k,faktura,out_data])
The function SQL Oracle looks like this:
QQ.ECOMMERCE.ZMIANA_OPISU_LIST_PRZEWOZOWY(P_NUMER_LISTU => :P_NUMER_LISTU,
P_KOD_KURIERA => :P_KOD_KURIERA,
P_NUMER_FAKTURY => :P_NUMER_FAKTURY,
P_ERROR_INFO => :P_ERROR_INFO);
Upvotes: 0
Views: 1723
Reputation: 8518
Try this
con = cx_Oracle.connect('***********')
cur = con.cursor()
faktura= 'QQ0009365/21'
numer_listu = '421435636356536'
kod_k = 112377
out_data = cur.var(str)
t = cur.callproc('QQ.ECOMMERCE.ZMIANA_OPISU_LIST_PRZEWOZOWY',[numer_listu,kod_k,faktura,out_data])
return out_data.getvalue()
except cx_Oracle.Error as error:
print(error)
Upvotes: 2
Reputation: 161
The out parameter must be declared as a cursor variable i.e.,
out_data = cursor.var(str)
The error indicates the wrong number of parameters are passed to the PL/SQL procedure.
Please go through the cx_Oracle documentation for calling pl/sql stored procedures through cx_Oracle: https://cx-oracle.readthedocs.io/en/latest/user_guide/plsql_execution.html#plsqlproc
Upvotes: 1