You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by neil <nb...@aisoftware.com.au> on 2002/05/17 03:48:42 UTC

esql v1.22 multiple returned update counts and ResultSets

Hi,
it seems that a few cocoon users like me, are hacking about with esql to get
it to do what we need. I'm working on the change shown below and am happy to
share it if anyone wants it.

JDBC can handle a sequence of values returned from a stored procedure, where
the values can be update counts and ResultSets in any order. It looks to me
like esql v1.22 will only handle a sequence with all the ResultSets before
the first update count and at most one update count. e.g.
ResultSet*updateCount? (where * and ? are as in a RE).

MS SqlServer stored procs return an update count for every
insert/update/delete performed and a ResultSet for every query (whose
results aren't consumed in the procedure) in the order that they are
performed. So its important to handle update counts and ResultSets in any
order.

Instead of esql.xsl code like:

      if (_esql_query.hasResultSet()) {
        do {
          // handle ResultSet
        } while(_esql_query.getMoreResults());
      } else {
        if (_esql_query.getStatement().getUpdateCount() &gt;= 0) {
          <xsl:apply-templates select="esql:update-results/*"/>
        }
        else{
          <xsl:apply-templates select="esql:no-results"/>
        }
      }

we need something that produces java code that looks like this:

String query = "{ ? = foo() }";
java.sql.CallableStatement cs = conn.prepareCall(
    query,
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY );

// The JDK javadocs say "If used, the result parameter must be
// registered as an OUT parameter".
// It doesn't matter what the Type is.
// esql will do this if instead of giving it "{ ? ="
// we give it "<esql:parameter direction="out" type="Int"/> ="
cs.registerOutParameter(1, java.sql.Types.INTEGER);

int resultCount = 0;
for ( boolean nextResultIsResultSet = cs.execute(); true;
nextResultIsResultSet = cs.getMoreResults() ) {
    if (nextResultIsResultSet) {
	java.sql.ResultSet rs = cs.getResultSet();
	++resultCount;
	// handle ResultSet
	rs.close();
    } else {
	// either the next result is an update count or there are no more results
	int updateCount = cs.getUpdateCount();
	if ( updateCount == -1 ) {
	    break; // no more results
	    // only finished when cs.getMoreResults() == false &&
cs.getUpdateCount() == -1
	    // awful bit of API but it works
	}
	++resultCount;
	// handle updateCount
    }
    // there may still be more ResultSets and/or update counts
}
if (resultCount == 0) {
    // no returned results
}

PRIVILEGED - PRIVATE AND CONFIDENTIAL
This email and any files transmitted with it are intended solely for the use
of the addressee(s) and may contain information which is confidential or
privileged. If you receive this email and you are not the addressee (or
responsible for delivery of the email to the addressee), please disregard
the contents of the email, delete the email and notify the author
immediately.
Before opening or using any attachments, please scan them for viruses and
defects. We do not accept any liability for loss or damage, which may arise
from your receipt of this e-mail. Our liability is limited to re-supplying
any affected attachments.




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.May.2002 -- 06:14 PM, Torsten Curdt wrote:
> On Friday 17 May 2002 16:34, Christian Haul wrote:
> > On 17.May.2002 -- 02:31 PM, Christian Haul wrote:
> > > On 17.May.2002 -- 12:23 PM, Torsten Curdt wrote:
> > > I would nest if(hasResultSet) into the switch statement. We would want
> > > to have multiple no-results / update-results blocks for each result,
> > > wouldn't we??
> >
> > OK, did your way since the XSL is simpler ;-)
> 
> ok
> 
> > Anyway, I've put the code into HEAD - please check. I'm off
> > 'till Wednesday so if I did break anything you'll have to live with it
> > 'till then or fix it ;-)
> 
> will do - guess I already found somehting...
> 
> the switch() should not use the getResultCount because of this:
> 
>                        getResultCount   but position() of result
> result                  1                 1
> update-result           2                 -
> result                  3                 2
> 
> we need the incrementing varibale as I proposed...
> but that's not a major biggy to fix ;-)

Torsten, my intention was to keep that var inside EsqlQuery and access
it via getResultCount(). It is incremented with every call to getMoreResults()

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Torsten Curdt <tc...@dff.st>.
On Friday 17 May 2002 16:34, Christian Haul wrote:
> On 17.May.2002 -- 02:31 PM, Christian Haul wrote:
> > On 17.May.2002 -- 12:23 PM, Torsten Curdt wrote:
> > I would nest if(hasResultSet) into the switch statement. We would want
> > to have multiple no-results / update-results blocks for each result,
> > wouldn't we??
>
> OK, did your way since the XSL is simpler ;-)

ok

> Anyway, I've put the code into HEAD - please check. I'm off
> 'till Wednesday so if I did break anything you'll have to live with it
> 'till then or fix it ;-)

will do - guess I already found somehting...

the switch() should not use the getResultCount because of this:

                       getResultCount   but position() of result
result                  1                 1
update-result           2                 -
result                  3                 2

we need the incrementing varibale as I proposed...
but that's not a major biggy to fix ;-)

cheers
--
Torsten

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.May.2002 -- 02:31 PM, Christian Haul wrote:
> On 17.May.2002 -- 12:23 PM, Torsten Curdt wrote:
> I would nest if(hasResultSet) into the switch statement. We would want
> to have multiple no-results / update-results blocks for each result,
> wouldn't we??

OK, did your way since the XSL is simpler ;-)

Anyway, I've put the code into HEAD - please check. I'm off 
'till Wednesday so if I did break anything you'll have to live with it
'till then or fix it ;-)

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.May.2002 -- 12:23 PM, Torsten Curdt wrote:
> <snip/>
> 
> > > getMoreResults() should return no resultset at all... but how to iterate
> > > to the next update count? again - it belongs to the statement...
> >
> > I read the JDBC API that way that getMoreResults() closes the current
> > ResultSet and switches to the next result. A result consists among
> > others of a ResultSet and an UpdateCount. At least I get the
> > impression from the docs. So, if a complex statement i.e. a stored
> > procedure produces several results, why shouldn't it return several
> > update counts as well?
> 
> ...
> 
> > So with the scenario above, it would still work as each call to
> > getMoreResults() would switch to the next result. Incidently
> > containing no result set but an update count.
> 
> makes sense... I also looked into the code I guess we should change it into 
> something like this then:
> 
>      do {
>        if (_esql_query.hasResultSet()) {
>           _esql_query.getResultRows();
> 
>           if (_esql_query.nextRow()) {
>             <xsl:apply-templates select="esql:results"/>
>           }
>           else {
>             <xsl:apply-templates select="esql:no-results"/>
>           }
>           _esql_query.getResultSet().close();
>        }
>        else {
>           if (_esql_query.getStatement().getUpdateCount() &gt; 0) {
>              <xsl:apply-templates select="esql:update-results/*"/>
>           }
>           else{
>              <xsl:apply-templates select="esql:no-results"/>
>           }
>        }
>      } while(_esql_query.getMoreResults());
> 
> what do you think?

Great. What happens when a result contains no ResultSet? Would we want
to evaluate <esql:no-results/>? (I don't think so).

> We could work around by wrapping the esql:results in a switch/case statement 
> so with multiple resultset it would get expanded into:
> 
>      int _esql_resultset_nr = 0;
>      do {
>        if (_esql_query.hasResultSet()) {
>           _esql_query.getResultRows();
> 
>           if (_esql_query.nextRow()) {
>             switch(_esql_resultset_nr++) {
>               case 1: /* resultset position() = 1 goes here */ break;
>               case 2: /* resultset position() = 2 goes here */ break;
>               ...

I would nest if(hasResultSet) into the switch statement. We would want
to have multiple no-results / update-results blocks for each result,
wouldn't we??

>             }
>           }
>           else {
>             <xsl:apply-templates select="esql:no-results"/>
>           }
>           _esql_query.getResultSet().close();
>        }
>        else {
>           if (_esql_query.getStatement().getUpdateCount() &gt; 0) {
>              <xsl:apply-templates select="esql:update-results/*"/>
>           }
>           else{
>              <xsl:apply-templates select="esql:no-results"/>
>           }
>        }
>      } while(_esql_query.getMoreResults());
> 
> So all you whould need to do is to specify multiple esql:results which get 
> applied in the order of appearance.

Great. Have already started to modify EsqlQuery.... :-)

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Torsten Curdt <tc...@dff.st>.
<snip/>

> > getMoreResults() should return no resultset at all... but how to iterate
> > to the next update count? again - it belongs to the statement...
>
> I read the JDBC API that way that getMoreResults() closes the current
> ResultSet and switches to the next result. A result consists among
> others of a ResultSet and an UpdateCount. At least I get the
> impression from the docs. So, if a complex statement i.e. a stored
> procedure produces several results, why shouldn't it return several
> update counts as well?

...

> So with the scenario above, it would still work as each call to
> getMoreResults() would switch to the next result. Incidently
> containing no result set but an update count.

makes sense... I also looked into the code I guess we should change it into 
something like this then:

     do {
       if (_esql_query.hasResultSet()) {
          _esql_query.getResultRows();

          if (_esql_query.nextRow()) {
            <xsl:apply-templates select="esql:results"/>
          }
          else {
            <xsl:apply-templates select="esql:no-results"/>
          }
          _esql_query.getResultSet().close();
       }
       else {
          if (_esql_query.getStatement().getUpdateCount() &gt; 0) {
             <xsl:apply-templates select="esql:update-results/*"/>
          }
          else{
             <xsl:apply-templates select="esql:no-results"/>
          }
       }
     } while(_esql_query.getMoreResults());

what do you think?

<snip/>

> Is it? AFAIK we evalute the <esql:results/> block for each result. How
> would I write different code for each result?

sorry, looking at the code revealed I didn't recalle correctly... the 
structure of results has to be same... you were right...

We could work around by wrapping the esql:results in a switch/case statement 
so with multiple resultset it would get expanded into:

     int _esql_resultset_nr = 0;
     do {
       if (_esql_query.hasResultSet()) {
          _esql_query.getResultRows();

          if (_esql_query.nextRow()) {
            switch(_esql_resultset_nr++) {
              case 1: /* resultset position() = 1 goes here */ break;
              case 2: /* resultset position() = 2 goes here */ break;
              ...
            }
          }
          else {
            <xsl:apply-templates select="esql:no-results"/>
          }
          _esql_query.getResultSet().close();
       }
       else {
          if (_esql_query.getStatement().getUpdateCount() &gt; 0) {
             <xsl:apply-templates select="esql:update-results/*"/>
          }
          else{
             <xsl:apply-templates select="esql:no-results"/>
          }
       }
     } while(_esql_query.getMoreResults());

So all you whould need to do is to specify multiple esql:results which get 
applied in the order of appearance.

What do you think?
--
Torsten

PS:maybe we should better move this discussion to cocoon-dev

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.May.2002 -- 11:12 AM, Torsten Curdt wrote:
> On Friday 17 May 2002 10:36, Christian Haul wrote:
> > On 17.May.2002 -- 10:01 AM, Torsten Curdt wrote:
> > > On Friday 17 May 2002 03:48, neil wrote:
> >
> > I believe that we actually should expect
> >
> > (resultset, update count)
> >
> >    | getMoreResults()
> >
> >    V
> > (resultset, update count)
> 
> well, but what will change the update count on the statement? how do you 
> iterate through it if you have no resultset at all but only update counts
> 
> update count
> update count
> update count
> 
> getMoreResults() should return no resultset at all... but how to iterate to 
> the next update count? again - it belongs to the statement...

I read the JDBC API that way that getMoreResults() closes the current
ResultSet and switches to the next result. A result consists among
others of a ResultSet and an UpdateCount. At least I get the
impression from the docs. So, if a complex statement i.e. a stored
procedure produces several results, why shouldn't it return several
update counts as well?

So with the scenario above, it would still work as each call to
getMoreResults() would switch to the next result. Incidently
containing no result set but an update count.

> > So the real question would be IMHO how should ESQL react with respect
> > to multiple ResultSets? Something like introducing an index attribute?
> 
> Well, current esql can already cope with multiple resultsets... question is 
> only update counts fit into this. since AFAICS they are tied to the 
> statement. see above
> 
> >    <esql:results index="1">
> >      ...
> >    </esql:results>
> >    <esql:update-results index="1">
> >      ...
> >    </esql:update-results>
> >    <esql:results index="2">
> >      ...
> >    </esql:results>
> >    <esql:update-results index="2">
> >      ...
> >    </esql:update-results>
> 
> well, that's not necessary since this can easily addressed with xpath.

Sure. Just thought it would be more intuitive for users to number
resultsets explicitly.

> > Afterall, each ResultSet may have a different structure and semantics.
> 
> sure... should already be taken care of

Is it? AFAIK we evalute the <esql:results/> block for each result. How
would I write different code for each result?

> > BTW can anyone remember what more-results are supposed to mean?
> 
> yes :-) 
> 
> it's for the limit clause... we use esql for paging though a resultset (like 
> google)

Oh yes! That's what I thought. But thinking about multiple result sets
made me wonder if it was supposed be stem from this area. Thanks for
the explanation, anyway.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Torsten Curdt <tc...@dff.st>.
On Friday 17 May 2002 10:36, Christian Haul wrote:
> On 17.May.2002 -- 10:01 AM, Torsten Curdt wrote:
> > On Friday 17 May 2002 03:48, neil wrote:
> > > Hi,
> > > it seems that a few cocoon users like me, are hacking about with esql
> > > to get it to do what we need. I'm working on the change shown below and
> > > am happy to share it if anyone wants it.
> > >
> > > JDBC can handle a sequence of values returned from a stored procedure,
> > > where the values can be update counts and ResultSets in any order. It
> > > looks to me like esql v1.22 will only handle a sequence with all the
> > > ResultSets before the first update count and at most one update count.
> > > e.g. ResultSet*updateCount? (where * and ? are as in a RE).
> > >
> > > MS SqlServer stored procs return an update count for every
> > > insert/update/delete performed and a ResultSet for every query (whose
> > > results aren't consumed in the procedure) in the order that they are
> > > performed. So its important to handle update counts and ResultSets in
> > > any order.
> >
> > Let's assume you expect:
> >
> > resultset
> > update count
> > resultset
> > update count
> >
> > How do you iterate through the update counts? AFAIK the JDBC API provides
> > only information about the update count in the Statement. This is why
> > current esql is like it is.
>
> I believe that we actually should expect
>
> (resultset, update count)
>
>    | getMoreResults()
>
>    V
> (resultset, update count)

well, but what will change the update count on the statement? how do you 
iterate through it if you have no resultset at all but only update counts

update count
update count
update count

getMoreResults() should return no resultset at all... but how to iterate to 
the next update count? again - it belongs to the statement...

> So the real question would be IMHO how should ESQL react with respect
> to multiple ResultSets? Something like introducing an index attribute?

Well, current esql can already cope with multiple resultsets... question is 
only update counts fit into this. since AFAICS they are tied to the 
statement. see above

>    <esql:results index="1">
>      ...
>    </esql:results>
>    <esql:update-results index="1">
>      ...
>    </esql:update-results>
>    <esql:results index="2">
>      ...
>    </esql:results>
>    <esql:update-results index="2">
>      ...
>    </esql:update-results>

well, that's not necessary since this can easily addressed with xpath.

> Afterall, each ResultSet may have a different structure and semantics.

sure... should already be taken care of

> > > int resultCount = 0;
> > > for ( boolean nextResultIsResultSet = cs.execute(); true;
> > > nextResultIsResultSet = cs.getMoreResults() ) {
>
>          //if (nextResultIsResultSet) {
>
> > > 	java.sql.ResultSet rs = cs.getResultSet();
> > > 	++resultCount;
>
>         switch (resultCount) {
>           1: //handle ResultSet 1
> 		    rs.close();
> 		   	int updateCount = cs.getUpdateCount();
> 			if ( updateCount == -1 ) {
> 			    // handle UpdateResults 1
>              break;
>           2: //handle ResultSet 2
> 		    rs.close();
> 		   	int updateCount = cs.getUpdateCount();
> 			if ( updateCount == -1 ) {
> 			    // handle UpdateResults 2
>              break;
>           default: // handle ResultSet without index
>         }
>
> > > }
> > > if (resultCount == 0) {
> > >     // no returned results
> > > }
> >
> > note that you are always calling getUpdateCount on the same statement.
> > will it's state be changed?!? That would be indeed a ugly behaviour...
>
> BTW can anyone remember what more-results are supposed to mean?

yes :-) 


it's for the limit clause... we use esql for paging though a resultset (like 
google)


so depending on if there are previous rows or rows after the limit has reached 
you get:

<esql:previous-rows>
 ...
</esql:previous-rows>

and

<esql:more-rows>
 ...
</esql:more-rows>

where you can put your e.g. links in
--
Torsten


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.May.2002 -- 10:01 AM, Torsten Curdt wrote:
> On Friday 17 May 2002 03:48, neil wrote:
> > Hi,
> > it seems that a few cocoon users like me, are hacking about with esql to
> > get it to do what we need. I'm working on the change shown below and am
> > happy to share it if anyone wants it.
> >
> > JDBC can handle a sequence of values returned from a stored procedure,
> > where the values can be update counts and ResultSets in any order. It looks
> > to me like esql v1.22 will only handle a sequence with all the ResultSets
> > before the first update count and at most one update count. e.g.
> > ResultSet*updateCount? (where * and ? are as in a RE).
> >
> > MS SqlServer stored procs return an update count for every
> > insert/update/delete performed and a ResultSet for every query (whose
> > results aren't consumed in the procedure) in the order that they are
> > performed. So its important to handle update counts and ResultSets in any
> > order.
> 
> Let's assume you expect:
> 
> resultset
> update count
> resultset
> update count
> 
> How do you iterate through the update counts? AFAIK the JDBC API provides only 
> information about the update count in the Statement. This is why current esql 
> is like it is.

I believe that we actually should expect

(resultset, update count)
   |
   | getMoreResults()
   V
(resultset, update count)

So the real question would be IMHO how should ESQL react with respect
to multiple ResultSets? Something like introducing an index attribute?

   <esql:results index="1">
     ...
   </esql:results>
   <esql:update-results index="1">
     ...
   </esql:update-results>
   <esql:results index="2">
     ...
   </esql:results>
   <esql:update-results index="2">
     ...
   </esql:update-results>

Afterall, each ResultSet may have a different structure and semantics.

> > int resultCount = 0;
> > for ( boolean nextResultIsResultSet = cs.execute(); true;
> > nextResultIsResultSet = cs.getMoreResults() ) {
         //if (nextResultIsResultSet) {
> > 	java.sql.ResultSet rs = cs.getResultSet();
> > 	++resultCount;
        switch (resultCount) {
          1: //handle ResultSet 1
		    rs.close();
		   	int updateCount = cs.getUpdateCount();
			if ( updateCount == -1 ) {
			    // handle UpdateResults 1
             break;
          2: //handle ResultSet 2
		    rs.close();
		   	int updateCount = cs.getUpdateCount();
			if ( updateCount == -1 ) {
			    // handle UpdateResults 2
             break;
          default: // handle ResultSet without index
        }
> > }
> > if (resultCount == 0) {
> >     // no returned results
> > }
> 
> note that you are always calling getUpdateCount on the same statement. will 
> it's state be changed?!? That would be indeed a ugly behaviour...

BTW can anyone remember what more-results are supposed to mean?

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: esql v1.22 multiple returned update counts and ResultSets

Posted by Torsten Curdt <tc...@dff.st>.
On Friday 17 May 2002 03:48, neil wrote:
> Hi,
> it seems that a few cocoon users like me, are hacking about with esql to
> get it to do what we need. I'm working on the change shown below and am
> happy to share it if anyone wants it.
>
> JDBC can handle a sequence of values returned from a stored procedure,
> where the values can be update counts and ResultSets in any order. It looks
> to me like esql v1.22 will only handle a sequence with all the ResultSets
> before the first update count and at most one update count. e.g.
> ResultSet*updateCount? (where * and ? are as in a RE).
>
> MS SqlServer stored procs return an update count for every
> insert/update/delete performed and a ResultSet for every query (whose
> results aren't consumed in the procedure) in the order that they are
> performed. So its important to handle update counts and ResultSets in any
> order.

Let's assume you expect:

resultset
update count
resultset
update count

How do you iterate through the update counts? AFAIK the JDBC API provides only 
information about the update count in the Statement. This is why current esql 
is like it is.

> int resultCount = 0;
> for ( boolean nextResultIsResultSet = cs.execute(); true;
> nextResultIsResultSet = cs.getMoreResults() ) {
>     if (nextResultIsResultSet) {
> 	java.sql.ResultSet rs = cs.getResultSet();
> 	++resultCount;
> 	// handle ResultSet
> 	rs.close();
>     } else {
> 	// either the next result is an update count or there are no more results
> 	int updateCount = cs.getUpdateCount();
> 	if ( updateCount == -1 ) {
> 	    break; // no more results
> 	    // only finished when cs.getMoreResults() == false &&
> cs.getUpdateCount() == -1
> 	    // awful bit of API but it works
> 	}
> 	++resultCount;
> 	// handle updateCount
>     }
>     // there may still be more ResultSets and/or update counts
> }
> if (resultCount == 0) {
>     // no returned results
> }

note that you are always calling getUpdateCount on the same statement. will 
it's state be changed?!? That would be indeed a ugly behaviour...
--
Torsten

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>