Re: Multiple return values and assignment
От | Jasen Betts |
---|---|
Тема | Re: Multiple return values and assignment |
Дата | |
Msg-id | gt3rgq$f6m$1@reversiblemaps.ath.cx обсуждение исходный текст |
Ответ на | Multiple return values and assignment ("Leif B. Kristensen" <leif@solumslekt.org>) |
Ответы |
Re: Multiple return values and assignment
|
Список | pgsql-sql |
On 2009-04-25, Leif B. Kristensen <leif@solumslekt.org> wrote: > I've got a function that returns both an integer and a string as a > user-defined composite type int_text: > > -- CREATE TYPE int_text AS (number INTEGER, string TEXT); > > Basically, the function does some heuristics to extract a sort order > number from a text, and conditionally modify the text: > > CREATE OR REPLACE FUNCTION get_sort(INTEGER, INTEGER, TEXT) > RETURNS int_text AS $$ ... > To use the two values in an other function where I've declared a > variable sort_text of type int_text, I do like this: > > SELECT number, string FROM get_sort(par_id, srt, txt) INTO sort_text; the above is equivalent to sort_text = get_sort(par_id, srt, txt); > srt := sort_text.number; > txt := sort_text.string; > But I feel it's a little awkward. Is there a more elegant way to do it? SELECT * FROM get_sort(par_id, srt, txt) INTO srt,txt;
В списке pgsql-sql по дате отправления: