Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[help] I can't get new ID after execute CallableStatement

0 views
Skip to first unread message

Woosung You

unread,
Nov 9, 2001, 3:29:09 PM11/9/01
to
Earlier, somebody posted this issue and nobody answered.
So please let me know whether it is known bug or it is my fault.

I have stored procedure called insert(?, ?, ?, ?,?, ?)
the first parameter is output parameter I registed as it is.

and when I try to get the output parameter using
stmt.getInt(1)

it throws following Exception

java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]The requested data
is not available.

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.base.BaseData.convert(Unknown Source)

at com.microsoft.jdbc.base.BaseData.getData(Unknown Source)

at com.microsoft.jdbc.base.BaseCallableStatement.getInt(Unknown Source)

_____________________________________

could anybody help with this issue?

Thanks.
Woosung You


Joseph Weinstein

unread,
Nov 9, 2001, 3:42:52 PM11/9/01
to Woosung You

Woosung You wrote:
>
> Earlier, somebody posted this issue and nobody answered.
> So please let me know whether it is known bug or it is my fault.

Hi. The issue is very likely that you have not yet processed
all the results and/or update counts that your procedure sends back
before sending the output parameter values. Here is how you should
process all the results of any CallableStatements:

boolean isAResultSetTheFirstThingReturned = cstmt1.execute();

while (true)
{
int updateCount = cstmt1.getUpdateCount();
ResultSet rs = cstmt1.getResultSet();

// When there are no more results *or* counts, we're done.
if (rs == null && updateCount == -1)
break;

// Check to see if there is a ResultSet
if (rs != null) {
while (rs.next()) {
System.out.println("Get first col by id:" + rs.getString(1));
}
rs.close();
} // Otherwise, there will be an update count
else {
System.out.println("Update count = " + cstmt1.getUpdateCount());
}
cstmt1.getMoreResults();
}

// Best to retrieve procedure status and/or output parameter values
// after all result sets and update counts have been retrieved.
System.out.println( "Output status: " + cstmt1.getInt(1));

Joe Weinstein at B.E.A.

0 new messages