Counting records in a PL/pgsql cursor

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Counting records in a PL/pgsql cursor
Дата
Msg-id 6BCB9D8A16AC4241919521715F4D8BCEA0FCEB@algol.sollentuna.se
обсуждение исходный текст
Ответы Re: Counting records in a PL/pgsql cursor  (Richard Huxton <dev@archonet.com>)
Re: Counting records in a PL/pgsql cursor  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Is there any way to count how many hits I got in a cursor in PL/pgsql?

I have a function that will "window" through the result of a (large)
query based on two parameters, but I also want to return the number of
hits to the client. Right now I'm looping through the entire cursor and
incrementing a local variable, which I later return (along with the
first <n> records in the resultset) to the client. But this seems
horribly inefficient... I'd just like to ask "how many rows are in this
cursor", is there a way to do that without looping through them all?


//Magnus

В списке pgsql-general по дате отправления:

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Is there anyway to...
Следующее
От: "SunWuKung"
Дата:
Сообщение: Catch multiple records when doing Select Into