From: | "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com> |
---|---|
To: | Mike Frisch <mfrisch(at)saturn(dot)tlug(dot)org> |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] Getting total records in result set |
Date: | 1999-04-10 16:50:16 |
Message-ID: | Pine.LNX.4.04.9904101243210.1354-100000@dragosani.lan2wan.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, 10 Apr 1999, Mike Frisch wrote:
> What is the easiest (and least system intensive) method of getting the
> total number of records in the result set? I am presently opening the
> cursor, doing a FETCH ALL, reading PQntuples(), closing the cursor, and
> reopening it for the 'real' work.
>
> Background: I am writing a CGI script that paginates the output from an
> SQL query and need to know a total number of records to calculate the
> number of pages to display.
>
> Is what I am going correct or is there a better way?
If you create a view with SQL, then do 'select count(*) from <viewname>',
you can just read the first (and only) row from THAT query. Can you then
create your cursor from the view?
Brett W. McCoy
http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
What garlic is to food, insanity is to art.
From | Date | Subject | |
---|---|---|---|
Next Message | Brett W. McCoy | 1999-04-10 16:55:06 | Re: [GENERAL] Oops... |
Previous Message | Mike Frisch | 1999-04-10 16:33:27 | Oops... |