Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Writing stored procedures : Using the OpenEdge SQL Java classes : INOUT and OUT parameters when one Java stored procedure calls another
INOUT and OUT parameters when one Java stored procedure calls another
If an OUT or INOUT parameter is of data type CHARACTER, then getParam() returns a Java String Object. You must declare a procedure variable of type String, and explicitly cast the value returned by getParam to type String. Before calling getParam() you must call the SQLCursor.wasNULL method to test whether the returned value is null. If getParam() is called for a null value, it raises a DhSQLException.
The getParam() method returns the value of an INOUT or OUT parameter identified by the number you specify in the fieldIndex parameter. getParam() returns the value as an object of the data type you specify in the fieldType parameter. Since getParam() returns the result as an instance of class Object, you must explicitly cast your inout_var variable to the correct data type.
These are the general steps to follow when calling one Java stored procedure from another:
1. Register OUT parameters in the calling stored procedure.
2. Declare Java variables in the snippet of the calling procedure.
3. Invoke the other stored procedure.
The following example illustrates the steps required for calling one Java stored procedure from another.
create procedure lotusp(
IN f1 char(50),
INOUT f2 char(50),
OUT f3 char(50)
)RESULT(f4 char(50))
f2 = new String("new rising sun");
f3 = new String("new rising lotus");
SQLResultSet.set(1, new String("the fog - the snow - the ice"));
commit work;
create procedure proc1()
String inout_param = new String("sun");
String out_param = new String();
SQLCursor call_proc = new SQLCursor("call lotusp(?,?,?)");
call_proc.setParam(1, new String("moon"));
call_proc.setParam(2, inout_param);
call_proc.registerOutParam(3, CHAR);
// OR you can specify the optional scale parameter
// call_proc.registerOutParam(3, CHAR, 15);;
inout_param = (String)call_proc.getParam(2, CHAR);
out_param = (String)call_proc.getParam(3, CHAR);