Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5FCDB47604A for ; Fri, 3 May 2002 17:26:11 -0400 (EDT) Received: from jbarilla.student.princeton.edu (jbarilla.student.Princeton.EDU [140.180.137.120]) by postgresql.org (Postfix) with ESMTP id 01021475983 for ; Fri, 3 May 2002 17:24:40 -0400 (EDT) Received: (from jbarilla@localhost) by jbarilla.student.princeton.edu (8.11.6/8.11.6) id g43LOfK14129; Fri, 3 May 2002 17:24:41 -0400 To: pgsql-sql Subject: Returning composite types from a plpgsql function From: Joseph Barillari X-Public-Key: finger -l jbarilla@phoenix.princeton.edu X-Public-Key-Fingerprint: 99C7 4F49 AF41 AD0F A4FC 529C 215E 1BD2 F6A1 FA37 X-URL: http://www.princeton.edu/~jbarilla Date: Fri, 03 May 2002 17:24:40 -0400 Message-ID: Lines: 37 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.50 (i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Archive-Number: 200205/20 X-Sequence-Number: 7656 --=-=-= Content-Transfer-Encoding: quoted-printable 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()=20 RETURNS tmp AS ' DECLARE=20 ret tmp%ROWTYPE; BEGIN=20 ret.a :=3D 1; ret.b :=3D 2; return ret;=20 END;'=20 LANGUAGE 'plpgsql'; Unfortunately, when I execute this, I get: cal=3D> select frob(); frob=20=20=20=20 ----------- 172795360 (1 row) Is there some sort of type coercion I have to do to get this to work? Thanks, Joe --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP MESSAGE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard iD8DBQE80wAZIV4b0vah+jcRAo1bAJ4otc/OlV8CNIMZ6RqOyB3O2la7mwCdG79I HtsXR772lcfaMI7nuLV88p8= =2J2P -----END PGP MESSAGE----- --=-=-=--