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() > 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() > 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
[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]>