X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6EEB847580B for ; Fri, 28 Mar 2003 18:19:49 -0500 (EST) Received: from lucifer.akyasociados.com.ar (unknown [200.69.203.237]) by postgresql.org (Postfix) with ESMTP id 5938B475458 for ; Fri, 28 Mar 2003 18:19:48 -0500 (EST) Received: from taz.oficina (taz.oficina [192.168.1.197]) (authenticated bits=0) by lucifer.akyasociados.com.ar (8.12.8/8.12.8) with ESMTP id h2SNNbkw073086 for ; Fri, 28 Mar 2003 20:23:37 -0300 (ART) (envelope-from franco@akyasociados.com.ar) From: Franco Bruno Borghesi Organization: AK y Asociados S.R.L. To: pgsql-sql@postgresql.org Subject: returning composite types. Date: Fri, 28 Mar 2003 20:20:25 -0300 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_5iNh+2Fzx+3NjJj"; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200303282020.25997.franco@akyasociados.com.ar> X-Spam-Status: No, hits=-12.9 required=5.0 tests=BAYES_01,PGP_SIGNATURE_2,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/632 X-Sequence-Number: 12670 --Boundary-02=_5iNh+2Fzx+3NjJj Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline Hi guys. I'm working with functions in my database, using plpgsql, but I reached a= =20 point where I realize I'm missing a concept: how do I return composite type= s=20 from a function? I'll give you an example: CREATE TYPE mytype AS( val1 INTEGER, val2 INTEGER, val3 INTEGER, val4 INTEGER=20=20=20 ); If I want my function to return a "mytype" type, should I declare it as: CREATE FUNCTION myFunction() RETURNS mytype AS ... or maybe CREATE FUNCTION myFunction() RETURNS SETOF mytype AS ... and in any case, inside the function, how should I declare the variable=20 holding the return value?: DECLARE result mytype; BEGIN ... RETURN result;=20=20=20 END;=20=20=20 or maybe=20=20=20=20=20=20 DECLARE result mytype%ROWTYPE; BEGIN ... RETURN result;=20=20=20 END;=20=20=20 I've read the documentation and the examples in it, but I still don't=20 understand what the right way is. If you could give an example of a functio= n=20 filling "mytipe" and returning it, it would really help me. Thanks in advance. =20=20=20 --Boundary-02=_5iNh+2Fzx+3NjJj Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+hNi5z/PwDAvtu7oRAoJhAJ9doVNEPef9OmU/hIAJWqACpTRwKQCeNrJM +fg9WUN+a8AePkqNpHoXXhc= =edP8 -----END PGP SIGNATURE----- --Boundary-02=_5iNh+2Fzx+3NjJj--