Re: Multiple return values and assignment - Mailing list pgsql-sql

From Jasen Betts
Subject Re: Multiple return values and assignment
Date
Msg-id gt3rgq$f6m$1@reversiblemaps.ath.cx
Whole thread Raw
In response to Multiple return values and assignment  ("Leif B. Kristensen" <leif@solumslekt.org>)
Responses Re: Multiple return values and assignment
List 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 by date:

Previous
From: landsharkdaddy
Date:
Subject: Re: Query with Parameters and Wildcards
Next
From: Jasen Betts
Date:
Subject: Re: varchar value comparisons not working?