| From: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> | 
|---|---|
| To: | Joe Conway <mail(at)joeconway(dot)com> | 
| Cc: | "Karl O(dot) Pinc" <kop(at)meme(dot)com>, Ron St-Pierre <rstpierre(at)syscor(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: Returning multiple values (but one row) in plpgsql | 
| Date: | 2004-09-08 21:10:45 | 
| Message-ID: | 20040908161045.K9813@mofo.meme.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Thanks!  I was not declaring the variable %rowtype.
Adding that fixed the problem.
On 2004.09.08 15:46 Joe Conway wrote:
> Karl O. Pinc wrote:
>> Anybody got a better idea?  Anybody know just when
>> this was fixed?  If I knew I might be able to see about
>> getting our site upgraded.  (I tried looking in the CVS
>> web interface, but was quickly daunted by the number of
>> source files.)
> 
> select version();
>                       version
> -------------------------------------------------------------------------
>  PostgreSQL 7.3.7 on x86_64-unknown-linux-gnu, compiled by GCC gcc 
> (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
> (1 row)
> 
> CREATE TYPE returntype AS (a INT, b INT);
> CREATE OR REPLACE FUNCTION return_multiple()
>    RETURNS setof returntype
>    LANGUAGE plpgsql
>    AS '
>    DECLARE
>      myvar returntype%rowtype;
>    BEGIN
>      myvar.a := 1;
>      myvar.b := 2;
>      RETURN NEXT myvar;
>      RETURN;
>    END;
> ';
> SELECT * FROM return_multiple();
>  a | b
> ---+---
>  1 | 2
> (1 row)
> 
> HTH,
> 
> Joe
Karl <kop(at)meme(dot)com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lee Harr | 2004-09-08 21:13:05 | function calls in WHERE clause | 
| Previous Message | Tom Lane | 2004-09-08 21:02:52 | Re: postgres start error |