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 [EMAIL PROTECTED] 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: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>