Re: full tuple count in cursor.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Cohen <alex(at)toomuchspace(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: full tuple count in cursor.
Date: 2004-05-10 11:44:10
Message-ID: 14660.1084189450@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Cohen <alex(at)toomuchspace(dot)com> writes:
> I have a cursor that i got from a select statement. I would like to
> know how many records are in the cursor so i dont go over the last one
> when using FETCH on the cursor. How can i do this?

You can't. The system does not know how many rows will be in the query
until it executes it. So the only way to obtain this information is to
FETCH the data. (Or MOVE over it, but that's only marginally faster,
and is probably a dead loss if you intend to FETCH the data anyway
later.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2004-05-10 11:50:22 Re: Cancel query based on a timeout
Previous Message Ivan Sergio Borgonovo 2004-05-10 10:55:48 passing strings to functions