Re: Find out the number of rows returned by refcursor?

Поиск
Список
Период
Сортировка
От Karen Hill
Тема Re: Find out the number of rows returned by refcursor?
Дата
Msg-id 1160589884.471707.195270@m73g2000cwd.googlegroups.com
обсуждение исходный текст
Ответ на Find out the number of rows returned by refcursor?  ("Karen Hill" <karen_hill22@yahoo.com>)
Ответы Re: Find out the number of rows returned by refcursor?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Karen Hill wrote:
> What is the best way to find out the total number of rows returned by
> an refcursor?  This would allow the client user to know the total
> amount of rows as they are using FETCH FORWARD/BACKWARD.
>
> For example let's say that an refcursor has 300 rows.  The user fetches
> 20 at a time.  I would like the user to know that there are 300
> possible rows.

I probably should re-phrase that question.

CREATE OR REPLACE FUNCTION foobar( refcursor ) RETURNS refcurser AS '
BEGIN
OPEN $1 FOR SELECT * FROM t ORDER by z;
END;
' LANGUAGE 'plpgsql';

BEGIN;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

-- Is there a way to know the total number of rows the cursor is
capable of traversing without using --count? Perhaps GET DIAGNOSTICS
ROW_COUNT?
SELECT foobar('mycursor');
-- I want to avoid using count(*) for performance reasons. Getting the
total number of rows the cursor --has.  I suspect it there is a system
variable that has this information...I just don't know which one it
--is.
SELECT COUNT(*) FROM t;

COMMIT;


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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Is it possible to return custom type as proper ROW?
Следующее
От: "Uwe C. Schroeder"
Дата:
Сообщение: Re: Is it possible to return custom type as proper ROW?