Re: return two elements
От | Michael Fuhr |
---|---|
Тема | Re: return two elements |
Дата | |
Msg-id | 20050608141632.GA71686@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: return two elements (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: return two elements
|
Список | pgsql-general |
On Wed, Jun 08, 2005 at 01:28:56AM -0400, Tom Lane wrote: > Alvaro Herrera <alvherre@surnet.cl> writes: > > Hmm, be aware that you can't return a set if you have OUT/INOUT > > parameters. > > ? News to me --- what are you worried about exactly? > > It's surely possible that our idea of what this means is different > from Oracle's, but we ought to take a close look before the semantics > get set in stone by a release ... I see the following in the development documentation -- are the semantics still under discussion? Should this thread be moved to pgsql-hackers? "If you declared the function with output parameters, write just RETURN NEXT with no expression. The current values of the output parameter variable(s) will be saved for eventual return. Note that you must declare the function as returning SETOF record when there are multiple output parameters, or SETOF sometype when there is just one output parameter of type sometype, in order to create a set-returning function with output parameters." http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING The following example works in HEAD: CREATE FUNCTION foo(INOUT y integer, OUT z integer) RETURNS SETOF record AS $$ BEGIN y := y + 1; z := y + 2; RETURN NEXT; y := y + 1; z := z + 3; RETURN NEXT; y := y + 1; z := z + 4; RETURN NEXT; END; $$ LANGUAGE plpgsql; SELECT * FROM foo(1); y | z ---+---- 2 | 4 3 | 7 4 | 11 (3 rows) -- Michael Fuhr http://www.fuhr.org/~mfuhr/
В списке pgsql-general по дате отправления: