IBM DB2 Manual page 151

Table of Contents

Advertisement

2. Associate the execution context with the CALL statement for the stored
procedure.
Do not use this execution context for any other purpose until you have
retrieved and processed the last result set.
3. For each result set:
a. Use the ExecutionContext method getNextResultSet to retrieve the result
set.
b. If you do not know the contents of the result set, use ResultSetMetaData
methods to retrieve this information.
c. Use an SQLJ result set iterator or JDBC ResultSet to retrieve the rows from
the result set.
Result sets are returned to the calling program in the same order that their cursors
are opened in the stored procedure. When there are no more result sets to retrieve,
getNextResultSet returns a null value.
getNextResultSet has two forms:
getNextResultSet();
getNextResultSet(int current);
When you invoke the first form of getNextResultSet, SQLJ closes the
currently-open result set and advances to the next result set. When you invoke the
second form of getNextResultSet, the value of current indicates what SQLJ does
with the currently-open result set before it advances to the next result set:
java.sql.Statement.CLOSE_CURRENT_RESULT
Specifies that the current ResultSet object is closed when the next ResultSet
object is returned.
java.sql.Statement.KEEP_CURRENT_RESULT
Specifies that the current ResultSet object stays open when the next ResultSet
object is returned.
java.sql.Statement.CLOSE_ALL_RESULTS
Specifies that all open ResultSet objects are closed when the next ResultSet
object is returned.
The following code calls a stored procedure that returns multiple result sets. For
this example, it is assumed that the caller does not know the number of result sets
to be returned or the contents of those result sets. It is also assumed that
autoCommit is false. The numbers to the right of selected statements correspond to
the previously-described steps.
Chapter 4. SQLJ application programming
135

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents