cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <tcu...@dff.st>
Subject Re: esql v1.22 multiple returned update counts and ResultSets
Date Fri, 17 May 2002 09:12:05 GMT
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message