0

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);
4
  • is any of those parameters in the procedure an output parameter ?? , like p_error_info Commented Sep 3, 2021 at 11:57
  • Yes, P_ERROR_INFO it is OUT parameter VARCHAR Commented Sep 3, 2021 at 12:04
  • the string parameters shouldn't be with single quotes, rather than double quotes, as some examples here --> blogs.oracle.com/oraclemagazine/… . I guess you have after that a variable to get the out return , right ? I have always used single quotes for the strings I pass to varchar2 variables in Oracle PL using callproc. Commented Sep 3, 2021 at 12:10
  • P_ERROR_INFO it's VARCHAR2 Commented Sep 3, 2021 at 12:51

2 Answers 2

2

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)        
Sign up to request clarification or add additional context in comments.

3 Comments

ORA-06550: linia 1, kolumna 7: PLS-00221: 'ZMIANA_OPISU_LIST_PRZEWOZOWY' is not a procedure or is undefined ORA-06550: linia 1, kolumna 7: PL/SQL: Statement ignored
does your user has execute privilege over this package ? It looks like it doesn't
I have all privilege for this procedure and database
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.