plpgsql returning resultset

Поиск
Список
Период
Сортировка
От tfinneid@student.matnat.uio.no
Тема plpgsql returning resultset
Дата
Msg-id 38087.134.32.140.234.1220350322.squirrel@webmail.uio.no
обсуждение исходный текст
Ответы Re: plpgsql returning resultset  (Raymond O'Donnell <rod@iol.ie>)
Список pgsql-general
Hi

I know the subject has been discussed before, but I dont find what any
information that helps me make it work, so please bear with me.

In pg 8.2 I want to write a function that gathers data from different
tables and joins it into a single resultset, similar to "select * from
tableA", but the problem I keep having is that I cant get the return to
work. I have tried return next and it fails. I have also tried refcursor,
but am not sure if that is the best way, its a littlebit cumbersome in a
program.

Are those the only two options? and what did I do wrong in the return next

create function test2() returns setof record as
$$
declare
   val_list record;
begin

   select * into val_list from tableA;
   return next val_list;
   return:
end
$$ .....


with the query:
    select test2();

ERROR: set-valued function called in context that cannot accept a set
CONTEXT: line 9 at return next

regards thomas


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

Предыдущее
От: Edoardo Panfili
Дата:
Сообщение: Re: immutable functions and enumerate type casts in indexes
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: immutable functions and enumerate type casts in indexes