Reputation: 20316
I need to call some PL/SQL procedures from my Java application. I can do it with JDBC. But the problem is that procedures are using the "PL/SQL Web Toolkit" and its packages (htp, owa _ util, owa _ cookie, ...). When I call them I get some exceptions as this:
Exception in thread "main" java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.OWA_UTIL", line 323
ORA-06512: at "SYS.HTP", line 859
ORA-06512: at "SYS.HTP", line 974
...
Is possible to call these procedures using a Java package or any other way?
I can't modify these procedures, but I can't create some.
Thanks for your help.
Upvotes: 1
Views: 1130
Reputation: 384
here's the sample code how you can do it ---
CallableStatement stmt = conn.prepareCall("? = call test(?)");
stmt.registerOutParameter(1, OracleTypes.INTEGER);
stmt.setString(2, "callIndex");
stmt.execute();
Integer outputValue = stmt.getInt(1);
here test is a stored function which is been called via java "callable statement".Also if you need to pass variables to stored procedure or a function in oracle, you have to OracleTypes to pass the correct variable up over there.
Upvotes: 0
Reputation: 8079
htf and htp assume that some things are going to be set up in advance. This is done automatically when the call goes through a PL/SQL gateway like mod_plsql. But it can also be done manually.
There's a good explanation on the Ask Toad wiki
To successfully use htp & htf, you'll need to define a couple variables and then initialize the cgi environment.
Upvotes: 2
Reputation: 146239
That error message means that you are passing an argument of the wrong datatype or assigning the result to a variable of the wrong datatype. You need to re-check your code and in particular its assignments. Alterntively you can post your code here: I'm sure one of the SO Brains will be able to spot the problem.
Incidentally, which method in OWA_UTIL are you calling?
Upvotes: 0