You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Antonio Gallardo <ag...@agsoftware.dnsalias.com> on 2002/12/27 00:08:56 UTC

Change in for postgresql

Hi!

I thinked about the problem of non-working <esql:more-results> tag with
PostgreSQL and the easy way to resolve this problem is to change in
PostgresEsqlQuery.java in line 85 from:


  if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows());

to:

  if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()+1);

that way, when we will request maxrows=4 the code will limit the query to
5 (4+1) and there will be another row that will trigger the
<esql:more-results> tag.

Please review this little change.

Thanks in advance,

Antonio Gallardo

Antonio Gallardo dijo:
> Hi:
>
> I was checking the code behind esql. I think the problem is related to
> the new LIMT OFFSET in the Query:
>
> If we set the limit of returned rows the database will return in the
> recordset only the numbers of rows that we requested with the LIMIT
> keyword. That means that we cannot know if there are more rows. XSP does
> not know it too and then the <esql:more-results> do nothing.
>
> I thinked that we can change this because one of the use of the
> <esql:more-results> tag is pagination. If we cannot know if there are
> more rows then we cannot make use of the "previous page" and "next page"
> approach.
>
> I hope you will resolve this issue or please tell us how to resolve
> this.
>
> Thanks in advance,
>
> Antonio Gallardo
>
>
>
> Antonio Gallardo dijo:
>> Hi!
>>
>> I am trying to make use of <esql:more-results> in a simple PostgreSQL
>> database page using XSP. I am using Cocoon 2.1 CVS (today - 25-Dic-02
>> at night CST). My problem is that the <esql:more-results> is not
>> working. I know already there are more than 50 registers of the
>> database that can be retrieved.
>>
>> <snip>
>> <esql:execute-query>
>>   <esql:query>
>>     <esql:use-limit-clause/>
>>     <esql:skip-rows>1</esql:skip-rows>
>>     <esql:max-rows>10</esql:max-rows>
>>     <esql:results>
>>       <table><header-stuff/>
>>         <esql:row-results>
>>           <esql:previous-results>previous rows</esql:previous-results>
>> <esql:more-results>more rows</esql:more-results>
>>           <td><esql:get-string column="name"/></td>
>>         </esql:row-results>
>>       </table>
>>     </esql:results>
>>   </esql:query>
>> </snip>
>>
>> The point is: everything works well but the more-results is not
>> working no matter if you put it as descendant of <esql:results> or
>> <esql:row-results>
>>
>> My database is PostgreSQL 7.2 on Red Hat Linux 7.2
>>
>> Please help me.
>>
>> Regards,
>>
>> Antonio Gallardo
>>
>>
>>
>> ---------------------------------------------------------------------
>> Please check that your question  has not already been answered in the
>> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>>
>> To unsubscribe, e-mail:     <co...@xml.apache.org>
>> For additional commands, e-mail:   <co...@xml.apache.org>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>




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

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


Re: Change in for postgresql

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Thanks! :-)

Antonio

Torsten Curdt dijo:
>> This is why I started thinking about this issue and suggested the
>> workaround. I think the solutions is not too ugly because is better to
>> get 5 rows in a resultset than 8,000 or more, just to get the row
>> number 5 and trigger the  tag.
>
>
> Thanks for reporting, Antonio.
>
> I've had a closer look. I think you are right. It's not too bad.
>
> If one uses the esql:row-count tag (which is an additional count query)
> it wouldn't be necessary to get another row because we know about the
> total number rows of the result. But since I don't wanna force to have a
>  count query for everyone using the more-results tag I think we are
> better off with the additional row - as you proposed.
>
> I added this to the javadocs and all the different database query
> implementations. Please crosscheck and report back if it works for you.
> --
> Torsten
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Change in for postgresql

Posted by Torsten Curdt <tc...@dff.st>.
> This is why I started thinking about this issue and suggested the
> workaround. I think the solutions is not too ugly because is better to get
> 5 rows in a resultset than 8,000 or more, just to get the row number 5 and
> trigger the  tag.


Thanks for reporting, Antonio.

I've had a closer look. I think you are right. It's not too bad.

If one uses the esql:row-count tag (which is an additional count query) 
it wouldn't be necessary to get another row because we know about the 
total number rows of the result. But since I don't wanna force to have a 
count query for everyone using the more-results tag I think we are 
better off with the additional row - as you proposed.

I added this to the javadocs and all the different database query 
implementations. Please crosscheck and report back if it works for you.
--
Torsten


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Change in for postgresql

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Hi Torsten:


I am also using:

<esql:use-limit-clause/>
<esql:skip-rows>1</esql:skip-rows>
<esql:max-rows>4</esql:max-rows>

You have no way to trigger the <esql:more-result> tag.

Currently in my test DB on PostgreSQL there are more that 8,000 rows and
this does not trigger the <esql:more-results> tag. As you can see I setted
the <esql:maxrows> to 4.

This is why I started thinking about this issue and suggested the
workaround. I think the solutions is not too ugly because is better to get
5 rows in a resultset than 8,000 or more, just to get the row number 5 and
trigger the <esql:more-results> tag.

Regards,

Antonio Gallardo.

Torsten Curdt dijo:
> I must have missed you previous posts... :-/
>
> <snip/>
>
>> to:
>>   if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()+1);
>>
>> that way, when we will request maxrows=4 the code will limit the query
>> to 5 (4+1) and there will be another row that will trigger the
>> <esql:more-results> tag.
>
> Hm... this sounds like an very ugly work around. We better check the
> loop and the more-results condition.
>
> <snip/>
>
>> > I was checking the code behind esql. I think the problem is related
>> to the new LIMT OFFSET in the Query:
>> >
>> > If we set the limit of returned rows the database will return in the
>> recordset only the numbers of rows that we requested with the LIMIT
>> keyword. That means that we cannot know if there are more rows. XSP
>> does not know it too and then the <esql:more-results> do nothing.
>
> This shouldn't be a problem since we (already) can get the total number
> of rows with a count query. (see the query classes)
>
> I'll have a look...
> --
> Torsten
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Change in for postgresql

Posted by Torsten Curdt <tc...@dff.st>.
I must have missed you previous posts... :-/

<snip/>

> to:
>   if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()+1);
>
> that way, when we will request maxrows=4 the code will limit the query to
> 5 (4+1) and there will be another row that will trigger the
> <esql:more-results> tag.

Hm... this sounds like an very ugly work around. We better check the
loop and the more-results condition.

<snip/>

> > I was checking the code behind esql. I think the problem is related to
> > the new LIMT OFFSET in the Query:
> >
> > If we set the limit of returned rows the database will return in the
> > recordset only the numbers of rows that we requested with the LIMIT
> > keyword. That means that we cannot know if there are more rows. XSP does
> > not know it too and then the <esql:more-results> do nothing.

This shouldn't be a problem since we (already) can get the total number
of rows with a count query. (see the query classes)

I'll have a look...
--
Torsten


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org