Can JDBC handle multiple record sets in a single callable statement.
Thanks in advance.
> Can JDBC handle multiple record sets in a single callable statement.
>
> Thanks in advance.
If you mean multiple resultsets, the answer is yes. All you need to do is use the
getMoreResults() method in java.sql.CallableStatement. Whether a JDBC driver supports it
or not depends on the individual driver. Check the docs of your driver.
Some drivers may handle it a different way. For instance, they allow a stored procedure
call to return a java.sql.Statement object which you use getMoreResults() on. This could
allow you to send multiple calls to the callable statement and receive multiple
resultsets from each call. Again, check your docs.

Signature
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
kjc - 09 Feb 2005 02:38 GMT
>>Can JDBC handle multiple record sets in a single callable statement.
>>
[quoted text clipped - 8 lines]
> allow you to send multiple calls to the callable statement and receive multiple
> resultsets from each call. Again, check your docs.
Thanks, this is exactly what i'm talking about.
The respective JDBC driver is the MSSql server driver, supplied by MS.
Joe Weinstein - 09 Feb 2005 04:06 GMT
>>> Can JDBC handle multiple record sets in a single callable statement.
>>>
>>> Thanks in advance.
>>
> Thanks, this is exactly what i'm talking about.
> The respective JDBC driver is the MSSql server driver, supplied by MS.
Here is an example, including the style for
processing all possible returns from a procedure
or complex SQL. This is a PreparedStatement,
but the same is true for a Callable Statement.
Just do the getXXX() calls for the output parameters
after the processing loop:
boolean getResultSet = ps.execute();
// handle all resultsets and/or update counts
while (true)
{
int updateCount = -1;
ResultSet r = null;
if (getResultSet)
{
r = ps.getResultSet();
while (r.next());
r.close();
}
else
{
updateCount = ps.getUpdateCount();
}
if ((r == null) && (updateCount == -1))
{
break; // done with loop
}
else
getResultSet = ps.getMoreResults();
}
HIH,
Joe Weinstein