From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Multiple return values and assignment |
Date: | 2009-04-27 08:48:26 |
Message-ID: | gt3rgq$f6m$1@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 2009-04-25, Leif B. Kristensen <leif(at)solumslekt(dot)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;
From | Date | Subject | |
---|---|---|---|
Next Message | Jasen Betts | 2009-04-27 08:53:49 | Re: varchar value comparisons not working? |
Previous Message | landsharkdaddy | 2009-04-27 05:01:14 | Re: Query with Parameters and Wildcards |