Wrong number or types of arguments in call to proc

2019-08-10 03:34发布

问题:

I took official example from http://www.jython.org/archive/21/docs/zxjdbc.html:

Oracle
>>> c = db.cursor() # open the database as in the examples above
>>> c.execute("create or replace function funcout (y out varchar2) return varchar2 is begin y := 'tested'; return 'returned'; end;")
>>> params = [None]
>>> c.callproc("funcout", params)
>>> print params

When I run this code I get exception:

PLS-00306: wrong number or types of arguments in call to 'FUNCOUT' ORA-06550: line 1, column 7: PL/SQL: Statement ignored

How to fix it?

Addition!!! Also does not work this code:

  outParam = ""
            self.cursor.execute("create or replace function funcout (y out varchar2) return varchar2 is begin y := 'tested'; return 'returned'; end;")
            self.cursor.callproc("funcout", [outParam])

回答1:

When you have an OUT or IN OUT parameter, you must pass a variable, not a literal for that parameter. How else can the procedure pass the value back?



回答2:

You can take a look at PLSQLSample.java