number of rows returned by a query
Maybe this question was discussed previously, but I could not find an
answer:
An application used PQntuples function to obtain number of tuples after
executing each query. Since number of rows increased we decided to use
DECLARE CURSOR/FETCH commands to retrieve tuples. However, it seems that
number of the tuples is not available after DECLARE CURSOR command. We want
to minimize the changes in the app. *Is it possible to obtain number of rows
that a cursor will return?*
Thank you
Konstantin
Hey Konstantin,
Use MOVE ALL, then PQcmdTuples to get number of rows,
then MOVE BACKWARD ALL to point cursor at initial position.
2010/12/2 Konstantin Izmailov <pgfizm@gmail.com>
Maybe this question was discussed previously, but I could not find an
answer:An application used PQntuples function to obtain number of tuples after
executing each query. Since number of rows increased we decided to use
DECLARE CURSOR/FETCH commands to retrieve tuples. However, it seems that
number of the tuples is not available after DECLARE CURSOR command. We want
to minimize the changes in the app. *Is it possible to obtain number of
rows that a cursor will return?*Thank you
Konstantin
--
// Dmitriy.
Dmitriy,
It worked like a charm! Bol'shoe spasibo!
I'm curious what are the Postgres versions that support MOVE ALL. The
documentation does not even mention "ALL" option.
Konstantin
On Thu, Dec 2, 2010 at 3:49 AM, Dmitriy Igrishin <dmitigr@gmail.com> wrote:
Show quoted text
Hey Konstantin,
Use MOVE ALL, then PQcmdTuples to get number of rows,
then MOVE BACKWARD ALL to point cursor at initial position.2010/12/2 Konstantin Izmailov <pgfizm@gmail.com>
Maybe this question was discussed previously, but I could not find an
answer:
An application used PQntuples function to obtain number of tuples after
executing each query. Since number of rows increased we decided to use
DECLARE CURSOR/FETCH commands to retrieve tuples. However, it seems that
number of the tuples is not available after DECLARE CURSOR command. We want
to minimize the changes in the app. *Is it possible to obtain number of
rows that a cursor will return?*Thank you
Konstantin--
// Dmitriy.
Le 03/12/2010 07:34, Konstantin Izmailov a �crit :
Dmitriy,
It worked like a charm! Bol'shoe spasibo!I'm curious what are the Postgres versions that support MOVE ALL. The
documentation does not even mention "ALL" option.
Actually, it does:
http://www.postgresql.org/docs/9.0/interactive/sql-fetch.html
(the move manpage tells to go see the fetch manpage: "The parameters for
the MOVE command are identical to those of the FETCH command; refer to
FETCH for details on syntax and usage. ")
BTW, all maintained releases (and even 7.4, and 8.0) support the "ALL"
option.
--
Guillaume
http://www.postgresql.fr
http://dalibo.com