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

From Joe Conway
Subject Re: Returning multiple values (but one row) in plpgsql
Date
Msg-id 413F72CC.1030007@joeconway.com
Whole thread Raw
In response to Re: Returning multiple values (but one row) in plpgsql  ("Karl O. Pinc" <kop@meme.com>)
Responses Referencing multiple values returned to a plpgsql function - Was: Re: Returning multiple values (but one row) in plpgsql
List pgsql-general
Karl O. Pinc wrote:
> Thanks!  I was not declaring the variable %rowtype.
> Adding that fixed the problem.
>

Ah yes, that works too. For the record:

CREATE TYPE returntype AS (a INT, b INT);
CREATE OR REPLACE FUNCTION return_multiple()
    RETURNS returntype
    LANGUAGE plpgsql
    AS '
    DECLARE
      myvar returntype%rowtype;
    BEGIN
      myvar.a := 1;
      myvar.b := 2;
      RETURN myvar;
    END;
';
SELECT * FROM return_multiple();
  a | b
---+---
  1 | 2
(1 row)

Joe

pgsql-general by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: Returning multiple values (but one row) in plpgsql
Next
From: Tom Lane
Date:
Subject: Re: postgres start error