cursors from pl/pgsql

Поиск
Список
Период
Сортировка
От Marc Menem
Тема cursors from pl/pgsql
Дата
Msg-id x2rd33b58461004061858s8da86aa8ibbf033a17be2f1af@mail.gmail.com
обсуждение исходный текст
Ответы Re: cursors from pl/pgsql  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: cursors from pl/pgsql  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
Hi all,

I'm trying to use a cursor returned by a function from another function. But I can't seem to get it working correctly. The error message is:
  ERROR:  cursor FOR loop must use a bound cursor variable
I am not sure how to bind it;

my code is similar to this:

create or replace function store_normalize(groupid_in varchar(20)) RETURNS int AS $$
DECLARE
    outputcursor refcursor;
    normrow_r record;
BEGIN
        perform normalize('outputcursor', groupid_in);
        for normrow_r in outputcursor loop
            insert into factordata(factorid, stockid, value, date)
            values (normrow_r.factorid, normrow_r.stockid, normrow_r.value, normrow_r.date);
        end loop;
        close ouputcursor;
        END LOOP;
     return 1;
END;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION normalize(outputcursor refcursor,
    groupid_in varchar(20)
) RETURNS refcursor AS $$
BEGIN

OPEN outputcursor FOR
select * from factordata where groupid = groupid_in;

    RETURN outputcursor;
END;
$$ LANGUAGE plpgsql;

cheers.
Marc

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: can't connect to server on localhost
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: "1-Click" installer problems