On 2/17/2011 1:45 AM, Thomas Mueller wrote:
Hi,

For H2, the statement "CALL" actually does return a result set. So I
wouldn't call it a 'bug'. However, it might be incompatible with other
databases. With which other database do you compare this?

Regards,
Thomas


I'm sure its a bug. Every database and JDBC driver I've used work the same way (MySQL, Derby, MSSQL, Sybase). CALL should only returns a ResultSet if the procedure returns one. Just check the documentation for execute(), getMoreResults(), getResultSet() and getUpdateCount()

According to the JDBC documentation:

execute() - The |execute| method executes an SQL statement and indicates the form of the first result. You must then use the methods |getResultSet| or |getUpdateCount| to retrieve the result, and |getMoreResults| to move to any subsequent result(s). *Returns:*|**true| if the next result is a |ResultSet| object; |false| if it is an update count or there are no more results, so a standard way to process a request would be:

    retCode=stmt.execute();
    // find first resultset, skip all update counts until we
    // find a resultset or no more results are found
    while(retCode==false && stmt.getUpdateCount()!=-1){
      retCode=getMoreResults();
    }
    if(retCode==true){
      // we found a resultset, query was a select or a procedure
      // that returned a resultset
      rs=getResultSet();
    }else{
      // no results sets from this query, either an update,insert,delete
      // or a procedure doing one of those commands
      rs=null;
    }

So if a procedure is in the format "ResultSet myProcedure(Connection)" it should return a ResultSet (execute() should return true), if its in the format "void myProcedure(Connection)" it should not (execute() should result false), right now H2 returns a ResultSet with the field name as the proc name, and the value as NULL.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to