From: Joseph Barillari <jbarilla@princeton.edu>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Returning composite types from a plpgsql function
Date: Fri, 03 May 2002 17:24:40 -0400
Message-ID: <m3offwaprb.fsf@washer.barillari.org> (raw)
Hi,
I've read in the mailing list archives that plpgsql does not support
assignment to array variables, so it is impossible to use them to
return data from a plpgsql function.
I'm curious as to how one might return more than one base type from
such a function, short of creating a temporary table and inserting the
value into that. For example:
CREATE TABLE tmp (a INTEGER, b INTEGER); --define the type
CREATE OR REPLACE FUNCTION frob()
RETURNS tmp AS '
DECLARE
ret tmp%ROWTYPE;
BEGIN
ret.a := 1;
ret.b := 2;
return ret;
END;'
LANGUAGE 'plpgsql';
Unfortunately, when I execute this, I get:
cal=> select frob();
frob
-----------
172795360
(1 row)
Is there some sort of type coercion I have to do to get this to work?
Thanks,
Joe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jbarilla@princeton.edu
Subject: Re: Returning composite types from a plpgsql function
In-Reply-To: <m3offwaprb.fsf@washer.barillari.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox