cursor empty

Поиск
Список
Период
Сортировка
От Philipp Kraus
Тема cursor empty
Дата
Msg-id C65B4D42-269A-4881-9F37-22B81FE8EE28@tu-clausthal.de
обсуждение исходный текст
Ответы Re: cursor empty  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hello,

I have got a function with this definition:

CREATE OR REPLACE FUNCTION vectorize(refcursor)
    RETURNS SETOF refcursor
    LANGUAGE 'plpgsql'
    COST 100
    STABLE
    ROWS 1000
AS $BODY$

begin
    perform pivottable(
        '_vector',
        'select * from viewdata',
        array['ideate', 'name', 'description', 'latitude', 'longitude'],
        array['parametername'],
        array['parametervalue::text', 'parametervaluetext']
    );
    open $1 scroll for select * from _vector;
    return next $1;
end

$BODY$;

The perform call creates a dynamic column pivot table, if I run manually

select pivottable(
    '_vector',
    'select * from viewdata',
    array['ideate', 'name', 'description', 'latitude', 'longitude'],
    array['parametername'],
    array['parametervalue::text', 'parametervaluetext']
);
select * from _vector;

I get all the data in the output, so everything is fine.

My goal is now to encapsulate the two lines into a function, so I define
a stable function and based on the dynamic column set a cursor. I get in
pgadmin the column names back, but the rows are empty if I run:

select * from vectorize('myvec');
fetch all from myvec;

Can you explain me, which part is wrong?
Thanks

Phil




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

Предыдущее
От: tango ward
Дата:
Сообщение: Re: KeyError: self._index[x]
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: cursor empty