db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-211) Network Server returns no result sets for a procedure call that returns no result
Date Thu, 30 Mar 2006 00:06:38 GMT
    [ http://issues.apache.org/jira/browse/DERBY-211?page=comments#action_12372343 ] 

Daniel John Debrunner commented on DERBY-211:
---------------------------------------------

Not sure there was clarity. Looking a little more, at the javadoc for Statement.executeUpdate,
if the same call was made using executeUpdate() then the correct return for executeUpdate
would be 0.

PreparedStatement.executeUpdate
"Returns:
    either (1) the row count for INSERT, UPDATE, or DELETE statements or (2) 0 for SQL statements
that return nothing"

Thus I believe the correct sequence here would be:

cs.executeUpdate() returns 0
cs.getUpdateCount() returns 0  // returns the current update count
cs.getMoreResults() returns false //  move to next result, false to indicate it is not a ResultSet
cs.getUpdateCount() returns -1 // indicates no more results

Thus to match, executing using cs.execute() would be

cs.execute() returns false
cs.getUpdateCount() returns 0 
cs.getMoreResults() returns false //  move to next result, false to indicate it is not a ResultSet
cs.getUpdateCount() returns -1 // indicates no more results

-------------------------------------------------------------------------------------------
Though maybe reading the javadoc  different way  one could say this is a valid sequence

cs.executeUpdate() returns 0
cs.getUpdateCount() returns -1  // no results (the 0 is not an update count)
cs.getMoreResults() returns false //  move to next result, false to indicate it is not a ResultSet
cs.getUpdateCount() returns -1  // no results

cs.execute() returns false
cs.getUpdateCount() returns -1 
cs.getMoreResults() returns false //  move to next result, false to indicate it is not a ResultSet
cs.getUpdateCount() returns -1 // indicates no more results

--------------------------------------------------------------------------

JDBC 4.0 proposed final draft clarifies this behaviour. The changes are:

section 13.2.4.2 JDBC 3.0 (executeUpdate)
"If the statement being executed returns a ResultSet object, an SQLException is
thrown."

changed to 

13.3.3.2 JDBC 4.0 (executeUpdate)

"If the stored procedure does not return a update count, the method executeUpdate
throws an SQLException."

This new text is in conflct with the javadoc for PreparedStatement.executeUpdate which has
not changed from JDBC 3.0.

Then this text is new in JDBC 4.0 section 13.3.3.3

"The method execute returns true if the first result is a ResultSet object and false
if it is an update count.
When the method execute returns true, the method getResultSet is called to retrieve
the ResultSet object. When execute returns false, the method getUpdateCount
returns an int. If this number is greater than or equal to zero, it indicates the update
count returned by the statement. If it is -1, it indicates that there are no more results."

Note this text points to the second approach in this comment, that getUpdateCount would return
-1.
However the first sentence does conflict the second, what if there is no update count?

I will send this to the JDBC 4.0 expert group.

> Network Server returns no result sets for a procedure call that returns no result
> ---------------------------------------------------------------------------------
>
>          Key: DERBY-211
>          URL: http://issues.apache.org/jira/browse/DERBY-211
>      Project: Derby
>         Type: Bug
>   Components: Network Server, Newcomer
>     Versions: 10.1.1.0
>     Reporter: Kathey Marsden

>
> For a call of a procedure with no dynamic results embedded 
> Cloudscape returns a one result, an update count of zero.  However, using the network
server no results are returned. We should be consistent.
> To reproduce 
> See call za() in lang/procedure.java test.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message