Before executing a stored procedure call, you must explicitly call registerOutParam() to register the type of each OUT and INOUT parameter.
The registerOutParam() method of the SQLCursor class registers the type of OUT and INOUT parameters.
Syntax
The format and arguments for the registerOutParam() method are as follows:
registerOutParam( param_num , data_type ) ;
Limit: The number of arguments is limited to 50.
The following example shows an excerpt from a stored procedure that uses registerOutParam() interface to register the OUT and INOUT parameters.
registerOutParam() Interface Example
CREATE PROCEDURE get_sal (IN cust_num INTEGER,
OUT dept_num INTEGER,
INOUT salary DOUBLE PRECISION
)
BEGIN
Integer dept = new Integer(40);
Double incr = 0.25;
// select department number into dept using cust_num.
dept_num = dept;
salary = new Double(salary.doubleValue() + (salary.doubleValue) *
incr.double_Value());
END
CREATE PROCEDURE call_get_sal()
BEGIN
Integer num = new Integer(54);
Double sal = new Double(25000.00);
SQLCursor cust_cur = new SQLCursor("call get_sal(?,?,?)");
cust_cur.setParam(1,num);
cust_cur.registerOutParam(2,INTEGER);
cust_cur.registerOutParam(3,DOUBLE);
cust_cur.setParam(3,sal);
cust_cur.open();
// process the data
cust_cur.close();
END
If all the OUT and INOUT parameters are not registered, then sql engine returns an error: error(-20161): Not all OUT/INOUT parameters are registered.