Re: Returning multiple values (but one row) in plpgsql

From: Joe Conway <mail(at)joeconway(dot)com>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: 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 20:59:56
Message-ID: 413F72CC.1030007@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-09-08 21:02:52 Re: postgres start error
Previous Message Gaetano Mendola 2004-09-08 20:51:00 Re: Salt in encrypted password in pg_shadow