I have to make some java procedure in Oracle with 'OUT' parameters. Procedure must be like this:
create or replace
procedure SomeProcedure(input1 IN VARCHAR2, result1 OUT VARCHAR2, result2 OUT VARCHAR2)
...
...
How do i do that? How i must specify Java class and method? How do I create stored procedure from this class and method? Any simple examples?
UPD : just solve that:
create or replace and compile java source named "TestOutParams" as
public class TestOutParams{
public static void someMethod(String[] value){
value[0] = "Hello";
}
};
/
create or replace procedure TestOutParams(value OUT VARCHAR2) as
language java
NAME 'TestOutParams.someMethod(java.lang.String[])';
/
SQL>var value VARCHAR2(40);
SQL>exec TestOutParams(:value);
PL/SQL procedure successfully completed.
SQL>PRINT value;
VALUE
---------
Hello
I dont know, why, but its working!
Well, it's something like this;
CallableStatement stmt = null;
stmt = conn.prepareCall("begin SomeProcedure(?,?,?); end;");
stmt.setString(1, new String("value1")); // Bind 1st input parameter
stmt.setString(2, new String("value2")); // Bind 2nd input parameter
stmt.registerOutParameter(3, Types.VARCHAR); // 3rd parameter is OUT
stmt.execute();
String retcod = new String(stmt.getInt(3));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.