Re: Returning multiple values (but one row) in plpgsql - Mailing list pgsql-general

From Karl O. Pinc
Subject Re: Returning multiple values (but one row) in plpgsql
Date
Msg-id 20040908161045.K9813@mofo.meme.com
Whole thread Raw
In response to Re: Returning multiple values (but one row) in plpgsql  (Joe Conway <mail@joeconway.com>)
Responses Re: Returning multiple values (but one row) in plpgsql
List 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@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: Returning multiple values (but one row) in plpgsql
Next
From: Joe Conway
Date:
Subject: Re: Returning multiple values (but one row) in plpgsql