Re: length of recordset read through a cursor

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: pgsql-sql(at)postgresql(dot)org, k(dot)p(dot)lehre(at)tiscali(dot)no
Subject: Re: length of recordset read through a cursor
Date: 2003-08-01 11:25:00
Message-ID: 3F2A4E0C.AB433D8@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> After declaring a cursor, one way of obtaining the length of the
resultset
> is to perform a "MOVE 0" and read the PQcmdStatus which returns a
"MOVE nn"
> where nn is the length of the resultset. (A negative MOVE can then be
used
> to allow starting to fetch records from the beginning of the
resultset.)
>
> Is there another, possibly faster way?
>
Looks like you're using libpq (because you mention PQcmdStatus),
then after declaring a cursor and FETCH ALL, try

1.3.4. Retrieving SELECT Result Information

PQntuples Returns the number of tuples (rows) in the query result.

int PQntuples(const PGresult *res);

I'm not exactly sure what you're trying to achieve or going to do,
so if I misunderstood you, ask again.

Regards, Christoph

Browse pgsql-sql by date

  From Date Subject
Next Message Mike Rylander 2003-08-01 12:41:49 Re: converting interval to timestamp
Previous Message btober 2003-08-01 01:28:18 Re: Does a the block of code within a stored procedure constitute a transaction?