Progress
SQL-92
Guide and Reference


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 datatype 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 datatype.

See the SQLCursor.getParam section in "Java Class Reference" for a complete description of syntax and parameters for the getParam method.

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
EXAMPLE

This 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))
BEGIN
     f2 = new String("new rising sun");
     f3 = new String("new rising lotus");
     SQLResultSet.set(1, new String("the fog - the snow - the ice"));
     SQLResultSet.insert();
END
 
commit work;
 
create procedure proc1()
BEGIN
     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);
     call_proc.open();
     inout_param = (String)call_proc.getParam(2, CHAR);
     out_param = (String)call_proc.getParam(3, CHAR);
     call_proc.close();
END 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095