Getting total records in result set

From: Mike Frisch <mfrisch(at)saturn(dot)tlug(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Getting total records in result set
Date: 1999-04-10 16:26:04
Message-ID: Pine.LNX.4.04.9904101222560.21460-100000@gateway.saturn.tlug.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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?

Thanks,

Mike.

======================================================================
Mike Frisch Email: mfrisch(at)saturn(dot)tlug(dot)org
Northstar Technologies WWW: http://saturn.tlug.org/~mfrisch
Newmarket, Ontario, CANADA
======================================================================

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Frisch 1999-04-10 16:33:27 Oops...
Previous Message Patrick Welche 1999-04-10 15:49:31 insert iff !exist