First, Sqlplus
For example, I have the following stored procedure in my database, how can I call the stored procedure and get the return value?
CREATE OR REPLACE
PROCEDURE test_procedure1
(
PARAM1 in VARCHAR2,
PARAM2 in Out varchar2,
PARAM3 in Out number)
is
BEGIN
PARAM2: = ' 88888 ';
PARAM3: = ' 0 ';
End Test_procedure1;
A general call to a stored procedure or function will think of calls or execute, but the problem is that the stored procedure has in-out parameters and should not use the above two commands.
So I was thinking of writing an anonymous pl/sql block to make the call. The code looks like this:
DECLARE
PARAM1 VARCHAR2 (ten);
PARAM2 VARCHAR2 (a);
PARAM3 number;
BEGIN
PARAM1: = ' 810 ';
PARAM2: = ' 1 ';
PARAM3: =1;
Test_procedure1 (PARAM1, PARAM2, PARAM3);
Dbms_output. Put_Line (PARAM2);
Dbms_output. Put_Line (PARAM3);
End;
Pl/sql Novice, if who has a better way please enlighten me.
Second, using Java calls
Conn: general JDBC Connection, Java Invoke main code as follows
CallableStatement call = Conn.preparecall ("{Call Test_procedure1 (?,?,?)}");
Call.setstring (1, "810");//incoming parameter 1
call.setstring (2, "1");//Pass in Parameter 2 (outgoing parameter 1)
Call.setint (3, 1);//Pass in Parameter 3 (pass Out parameter 2)
Call.registeroutparameter (2, Java.sql.Types.VARCHAR);//Outgoing parameter 1
call.registeroutparameter (3, JA Va.sql.Types.NUMERIC);//Outgoing parameter 2
call.execute ();
System.out.println (call.getstring (2));
System.out.println (Call.getint (3));