Re: Help making a plpgsql function?

Поиск
Список
Период
Сортировка
От Dany De Bontridder
Тема Re: Help making a plpgsql function?
Дата
Msg-id 200607051913.39707.dany@alchimerys.be
обсуждение исходный текст
Ответ на Help making a plpgsql function?  (Bjørn T Johansen <btj@havleik.no>)
Ответы Re: Help making a plpgsql function?  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
On Wednesday 05 July 2006 16:46, Bjørn T Johansen wrote:
> I need to make a funtion that take one parameter and then returns a
> "record" with x number of fields, collected from x no. of tables, i.e. I
> need to run several sql statemtents to collect all the needed values from x
> no. of fields and insert it into a "record" and return the "record" at the
> end...
From http://www.postgresql.org/docs/7.4/interactive/plpgsql-declarations.html

Example for function having return type set of record

create function testfunc(int) returns record as '
declare
        output record;
begin
        for output in select * from table1 where col1<$1 loop
        return next output;
        end loop;
return;
end;
' language plpgsql

executing through sql as:

select * from testfunc(6) as (col1 int, col2 float, col3 char(20));


Regards,

D.

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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Database connectivity using a unix shell
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Null and Void() - Or, Abandon All Hope Ye Who allow