db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: Returning java.sql.ResultSets from Java procedures
Date Mon, 05 Mar 2012 13:43:49 GMT
Thomas Hill <Thomas.K.Hill@t-online.de> writes:

> Hi,
> can someone please share an example how the Client side application code to call
> procedure looks like when I want my stored procedure to return TWO resultsets?
> The derby Wiki (extract see below) says 'WORK IN PROGRESS' in the section where
> documentation on this had been started.
>
> CallableStatement cs = conn.prepareCall("{ call DRS2(?, ?)}");
>   cs.setInt(1, p1);
>   cs.setInt(2, p2);
>   cs.execute();
>   WORK IN PROGESS 

Hi Thomas,

I've updated the example on the wiki so that the example now looks like
this:

  CallableStatement cs = conn.prepareCall("{ call DRS2(?, ?)}");
  cs.setInt(1, p1);
  cs.setInt(2, p2);

  boolean hasResults = cs.execute();

  while (hasResults) {
      ResultSet rs = cs.getResultSet();
      while (rs.next()) {
          // ....
      }
      rs.close();
      hasResults = cs.getMoreResults();
  }

-- 
Knut Anders

Mime
View raw message