From: | "Jim Buttafuoco" <jim(at)contactbda(dot)com> |
---|---|
To: | "Mark R(dot) Dingee" <mark(dot)dingee(at)cox(dot)net>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Multi-column returns from pgsql |
Date: | 2005-07-22 16:56:15 |
Message-ID: | 20050722165558.M96628@contactbda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Mark,
Instead of RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN NEXT rec;
then your select statement would be
select * from my_func() as (txt1 text,txt2 text);
Jim
---------- Original Message -----------
From: "Mark R. Dingee" <mark(dot)dingee(at)cox(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Sent: Fri, 22 Jul 2005 11:49:21 -0400
Subject: [SQL] Multi-column returns from pgsql
> Hi Everyone,
>
> Does anyone know if/how it's possible to return multi-column sets from a pgsql
> function? Right now I'm using something like the following as a work around
>
> CREATE OR REPLACE FUNCTION my_func() returns SETOF TEXT AS '
> DECLARE
> rec record;
> BEGIN
> FOR rec IN SELECT txt1, txt2 FROM mytable LOOP
> RETURN NEXT rec.txt1;
> RETURN NEXT rec.txt2;
> END LOOP;
> RETURN;
> END;' language 'plpgsql';
>
> which leaves me parsing multiple records to achieve the desired end result.
>
> Anyone have any thoughts?
>
> Thanks,
> Mark
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
------- End of Original Message -------
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2005-07-22 17:30:14 | Re: Convert numeric to money |
Previous Message | Mark R. Dingee | 2005-07-22 15:49:21 | Multi-column returns from pgsql |