Re: Howto return values from a function
От | Martijn van Oosterhout |
---|---|
Тема | Re: Howto return values from a function |
Дата | |
Msg-id | 20080515123608.GB25867@svana.org обсуждение исходный текст |
Ответ на | Howto return values from a function ("A B" <gentosaker@gmail.com>) |
Ответы |
Re: Howto return values from a function
Re: Howto return values from a function |
Список | pgsql-general |
On Thu, May 15, 2008 at 02:25:36PM +0200, A B wrote: > I'm still trying to learn to write plpgsql functions, but I find the > docs a little short on examples on how to return stuff from a > function. I'm very grateful for any help on this. What exactly about the documentation isn't clear? http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING > CREATE FUNCTION foo() RETURNS ???? AS > but what do I write instead of ???? Like the documentation says: SETOF sometype. > I'm nto sure here, but It seems to mee that there are two other ways > of doing case 2. How you generate the results is up to you. when you have them you either use RETURN NEXT or RETURN QUERY to return them to the caller. > 3) In the third case, I want to create the values I return by joining > many values. Something like this > CREATE FUNCTION foo() RETURNS ???? AS You can always use out parameters if you feel better about it: CREATE FUNCTION foo(col1 int4 OUT, col2 text OUT, ...) AS ... Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Please line up in a tree and maintain the heap invariant while > boarding. Thank you for flying nlogn airlines.
Вложения
В списке pgsql-general по дате отправления: