Re: how to get the total number of records in report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 19, 2010 at 1:18 AM, AI Rumman <rummandba@xxxxxxxxx> wrote:
Not actualy. I used pagination with limit clause in details query and I need the total number of records in the detail query.


Can you use a cursor?  Roughly...

BEGIN;
DECLARE x CURSOR FOR SELECT * FROM crm;
MOVE FORWARD ALL IN x;
MOVE BACKWARD ALL IN x;
MOVE FORWARD 100 IN x;
FETCH FORWARD 100 FROM x;
CLOSE x;
COMMIT;

Your  application would need to get the actual text result from the "MOVE FORWARD ALL IN x;" statement to know the total number of records from your SELECT.  After that, do your pagination via the "MOVE FORWARD 100 IN x;" and "FETCH FORWARD 100 FROM x;" statements.

HTH.
Greg

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux